
kernel:     file format elf32-i386


Disassembly of section .text:

00100000 <brelse>:
}

// Release the buffer b.
void
brelse(struct buf *b)
{
  100000:	55                   	push   %ebp
  100001:	89 e5                	mov    %esp,%ebp
  100003:	53                   	push   %ebx
  100004:	83 ec 14             	sub    $0x14,%esp
  100007:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if((b->flags & B_BUSY) == 0)
  10000a:	f6 03 01             	testb  $0x1,(%ebx)
  10000d:	74 57                	je     100066 <brelse+0x66>
    panic("brelse");

  acquire(&bcache.lock);
  10000f:	c7 04 24 e0 95 10 00 	movl   $0x1095e0,(%esp)
  100016:	e8 a5 42 00 00       	call   1042c0 <acquire>

  b->next->prev = b->prev;
  10001b:	8b 43 10             	mov    0x10(%ebx),%eax
  10001e:	8b 53 0c             	mov    0xc(%ebx),%edx
  100021:	89 50 0c             	mov    %edx,0xc(%eax)
  b->prev->next = b->next;
  100024:	8b 43 0c             	mov    0xc(%ebx),%eax
  100027:	8b 53 10             	mov    0x10(%ebx),%edx
  10002a:	89 50 10             	mov    %edx,0x10(%eax)
  b->next = bcache.head.next;
  10002d:	a1 14 ab 10 00       	mov    0x10ab14,%eax
  b->prev = &bcache.head;
  100032:	c7 43 0c 04 ab 10 00 	movl   $0x10ab04,0xc(%ebx)

  acquire(&bcache.lock);

  b->next->prev = b->prev;
  b->prev->next = b->next;
  b->next = bcache.head.next;
  100039:	89 43 10             	mov    %eax,0x10(%ebx)
  b->prev = &bcache.head;
  bcache.head.next->prev = b;
  10003c:	a1 14 ab 10 00       	mov    0x10ab14,%eax
  100041:	89 58 0c             	mov    %ebx,0xc(%eax)
  bcache.head.next = b;
  100044:	89 1d 14 ab 10 00    	mov    %ebx,0x10ab14

  b->flags &= ~B_BUSY;
  10004a:	83 23 fe             	andl   $0xfffffffe,(%ebx)
  wakeup(b);
  10004d:	89 1c 24             	mov    %ebx,(%esp)
  100050:	e8 fb 31 00 00       	call   103250 <wakeup>

  release(&bcache.lock);
  100055:	c7 45 08 e0 95 10 00 	movl   $0x1095e0,0x8(%ebp)
}
  10005c:	83 c4 14             	add    $0x14,%esp
  10005f:	5b                   	pop    %ebx
  100060:	5d                   	pop    %ebp
  bcache.head.next = b;

  b->flags &= ~B_BUSY;
  wakeup(b);

  release(&bcache.lock);
  100061:	e9 0a 42 00 00       	jmp    104270 <release>
// Release the buffer b.
void
brelse(struct buf *b)
{
  if((b->flags & B_BUSY) == 0)
    panic("brelse");
  100066:	c7 04 24 60 6c 10 00 	movl   $0x106c60,(%esp)
  10006d:	e8 ee 09 00 00       	call   100a60 <panic>
  100072:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  100079:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00100080 <bwrite>:
}

// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
  100080:	55                   	push   %ebp
  100081:	89 e5                	mov    %esp,%ebp
  100083:	83 ec 18             	sub    $0x18,%esp
  100086:	8b 45 08             	mov    0x8(%ebp),%eax
  if((b->flags & B_BUSY) == 0)
  100089:	8b 10                	mov    (%eax),%edx
  10008b:	f6 c2 01             	test   $0x1,%dl
  10008e:	74 0e                	je     10009e <bwrite+0x1e>
    panic("bwrite");
  b->flags |= B_DIRTY;
  100090:	83 ca 04             	or     $0x4,%edx
  100093:	89 10                	mov    %edx,(%eax)
  iderw(b);
  100095:	89 45 08             	mov    %eax,0x8(%ebp)
}
  100098:	c9                   	leave  
bwrite(struct buf *b)
{
  if((b->flags & B_BUSY) == 0)
    panic("bwrite");
  b->flags |= B_DIRTY;
  iderw(b);
  100099:	e9 32 20 00 00       	jmp    1020d0 <iderw>
// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
  if((b->flags & B_BUSY) == 0)
    panic("bwrite");
  10009e:	c7 04 24 67 6c 10 00 	movl   $0x106c67,(%esp)
  1000a5:	e8 b6 09 00 00       	call   100a60 <panic>
  1000aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

001000b0 <bread>:
}

// Return a B_BUSY buf with the contents of the indicated disk sector.
struct buf*
bread(uint dev, uint sector)
{
  1000b0:	55                   	push   %ebp
  1000b1:	89 e5                	mov    %esp,%ebp
  1000b3:	57                   	push   %edi
  1000b4:	56                   	push   %esi
  1000b5:	53                   	push   %ebx
  1000b6:	83 ec 1c             	sub    $0x1c,%esp
  1000b9:	8b 75 08             	mov    0x8(%ebp),%esi
  1000bc:	8b 7d 0c             	mov    0xc(%ebp),%edi
static struct buf*
bget(uint dev, uint sector)
{
  struct buf *b;

  acquire(&bcache.lock);
  1000bf:	c7 04 24 e0 95 10 00 	movl   $0x1095e0,(%esp)
  1000c6:	e8 f5 41 00 00       	call   1042c0 <acquire>

 loop:
  // Try for cached block.
  for(b = bcache.head.next; b != &bcache.head; b = b->next){
  1000cb:	8b 1d 14 ab 10 00    	mov    0x10ab14,%ebx
  1000d1:	81 fb 04 ab 10 00    	cmp    $0x10ab04,%ebx
  1000d7:	75 12                	jne    1000eb <bread+0x3b>
  1000d9:	eb 35                	jmp    100110 <bread+0x60>
  1000db:	90                   	nop
  1000dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1000e0:	8b 5b 10             	mov    0x10(%ebx),%ebx
  1000e3:	81 fb 04 ab 10 00    	cmp    $0x10ab04,%ebx
  1000e9:	74 25                	je     100110 <bread+0x60>
    if(b->dev == dev && b->sector == sector){
  1000eb:	3b 73 04             	cmp    0x4(%ebx),%esi
  1000ee:	66 90                	xchg   %ax,%ax
  1000f0:	75 ee                	jne    1000e0 <bread+0x30>
  1000f2:	3b 7b 08             	cmp    0x8(%ebx),%edi
  1000f5:	75 e9                	jne    1000e0 <bread+0x30>
      if(!(b->flags & B_BUSY)){
  1000f7:	8b 03                	mov    (%ebx),%eax
  1000f9:	a8 01                	test   $0x1,%al
  1000fb:	74 64                	je     100161 <bread+0xb1>
        b->flags |= B_BUSY;
        release(&bcache.lock);
        return b;
      }
      sleep(b, &bcache.lock);
  1000fd:	c7 44 24 04 e0 95 10 	movl   $0x1095e0,0x4(%esp)
  100104:	00 
  100105:	89 1c 24             	mov    %ebx,(%esp)
  100108:	e8 73 32 00 00       	call   103380 <sleep>
  10010d:	eb bc                	jmp    1000cb <bread+0x1b>
  10010f:	90                   	nop
      goto loop;
    }
  }

  // Allocate fresh block.
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
  100110:	8b 1d 10 ab 10 00    	mov    0x10ab10,%ebx
  100116:	81 fb 04 ab 10 00    	cmp    $0x10ab04,%ebx
  10011c:	75 0d                	jne    10012b <bread+0x7b>
  10011e:	eb 54                	jmp    100174 <bread+0xc4>
  100120:	8b 5b 0c             	mov    0xc(%ebx),%ebx
  100123:	81 fb 04 ab 10 00    	cmp    $0x10ab04,%ebx
  100129:	74 49                	je     100174 <bread+0xc4>
    if((b->flags & B_BUSY) == 0){
  10012b:	f6 03 01             	testb  $0x1,(%ebx)
  10012e:	66 90                	xchg   %ax,%ax
  100130:	75 ee                	jne    100120 <bread+0x70>
      b->dev = dev;
  100132:	89 73 04             	mov    %esi,0x4(%ebx)
      b->sector = sector;
  100135:	89 7b 08             	mov    %edi,0x8(%ebx)
      b->flags = B_BUSY;
  100138:	c7 03 01 00 00 00    	movl   $0x1,(%ebx)
      release(&bcache.lock);
  10013e:	c7 04 24 e0 95 10 00 	movl   $0x1095e0,(%esp)
  100145:	e8 26 41 00 00       	call   104270 <release>
bread(uint dev, uint sector)
{
  struct buf *b;

  b = bget(dev, sector);
  if(!(b->flags & B_VALID))
  10014a:	f6 03 02             	testb  $0x2,(%ebx)
  10014d:	75 08                	jne    100157 <bread+0xa7>
    iderw(b);
  10014f:	89 1c 24             	mov    %ebx,(%esp)
  100152:	e8 79 1f 00 00       	call   1020d0 <iderw>
  return b;
}
  100157:	83 c4 1c             	add    $0x1c,%esp
  10015a:	89 d8                	mov    %ebx,%eax
  10015c:	5b                   	pop    %ebx
  10015d:	5e                   	pop    %esi
  10015e:	5f                   	pop    %edi
  10015f:	5d                   	pop    %ebp
  100160:	c3                   	ret    
 loop:
  // Try for cached block.
  for(b = bcache.head.next; b != &bcache.head; b = b->next){
    if(b->dev == dev && b->sector == sector){
      if(!(b->flags & B_BUSY)){
        b->flags |= B_BUSY;
  100161:	83 c8 01             	or     $0x1,%eax
  100164:	89 03                	mov    %eax,(%ebx)
        release(&bcache.lock);
  100166:	c7 04 24 e0 95 10 00 	movl   $0x1095e0,(%esp)
  10016d:	e8 fe 40 00 00       	call   104270 <release>
  100172:	eb d6                	jmp    10014a <bread+0x9a>
      b->flags = B_BUSY;
      release(&bcache.lock);
      return b;
    }
  }
  panic("bget: no buffers");
  100174:	c7 04 24 6e 6c 10 00 	movl   $0x106c6e,(%esp)
  10017b:	e8 e0 08 00 00       	call   100a60 <panic>

00100180 <binit>:
  struct buf head;
} bcache;

void
binit(void)
{
  100180:	55                   	push   %ebp
  100181:	89 e5                	mov    %esp,%ebp
  100183:	83 ec 18             	sub    $0x18,%esp
  struct buf *b;

  initlock(&bcache.lock, "bcache");
  100186:	c7 44 24 04 7f 6c 10 	movl   $0x106c7f,0x4(%esp)
  10018d:	00 
  10018e:	c7 04 24 e0 95 10 00 	movl   $0x1095e0,(%esp)
  100195:	e8 96 3f 00 00       	call   104130 <initlock>
  // head.next is most recently used.
  struct buf head;
} bcache;

void
binit(void)
  10019a:	ba 04 ab 10 00       	mov    $0x10ab04,%edx
  10019f:	b8 14 96 10 00       	mov    $0x109614,%eax
  struct buf *b;

  initlock(&bcache.lock, "bcache");

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
  1001a4:	c7 05 10 ab 10 00 04 	movl   $0x10ab04,0x10ab10
  1001ab:	ab 10 00 
  bcache.head.next = &bcache.head;
  1001ae:	c7 05 14 ab 10 00 04 	movl   $0x10ab04,0x10ab14
  1001b5:	ab 10 00 
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    b->next = bcache.head.next;
  1001b8:	89 50 10             	mov    %edx,0x10(%eax)
    b->prev = &bcache.head;
  1001bb:	c7 40 0c 04 ab 10 00 	movl   $0x10ab04,0xc(%eax)
    b->dev = -1;
  1001c2:	c7 40 04 ff ff ff ff 	movl   $0xffffffff,0x4(%eax)
    bcache.head.next->prev = b;
  1001c9:	8b 15 14 ab 10 00    	mov    0x10ab14,%edx
  1001cf:	89 42 0c             	mov    %eax,0xc(%edx)
  initlock(&bcache.lock, "bcache");

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
  bcache.head.next = &bcache.head;
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
  1001d2:	89 c2                	mov    %eax,%edx
    b->next = bcache.head.next;
    b->prev = &bcache.head;
    b->dev = -1;
    bcache.head.next->prev = b;
    bcache.head.next = b;
  1001d4:	a3 14 ab 10 00       	mov    %eax,0x10ab14
  initlock(&bcache.lock, "bcache");

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
  bcache.head.next = &bcache.head;
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
  1001d9:	05 18 02 00 00       	add    $0x218,%eax
  1001de:	3d 04 ab 10 00       	cmp    $0x10ab04,%eax
  1001e3:	75 d3                	jne    1001b8 <binit+0x38>
    b->prev = &bcache.head;
    b->dev = -1;
    bcache.head.next->prev = b;
    bcache.head.next = b;
  }
}
  1001e5:	c9                   	leave  
  1001e6:	c3                   	ret    
  1001e7:	90                   	nop
  1001e8:	90                   	nop
  1001e9:	90                   	nop
  1001ea:	90                   	nop
  1001eb:	90                   	nop
  1001ec:	90                   	nop
  1001ed:	90                   	nop
  1001ee:	90                   	nop
  1001ef:	90                   	nop

001001f0 <consoleinit>:
  return n;
}

void
consoleinit(void)
{
  1001f0:	55                   	push   %ebp
  1001f1:	89 e5                	mov    %esp,%ebp
  1001f3:	83 ec 18             	sub    $0x18,%esp
  initlock(&cons.lock, "console");
  1001f6:	c7 44 24 04 86 6c 10 	movl   $0x106c86,0x4(%esp)
  1001fd:	00 
  1001fe:	c7 04 24 40 95 10 00 	movl   $0x109540,(%esp)
  100205:	e8 26 3f 00 00       	call   104130 <initlock>
  initlock(&input.lock, "input");
  10020a:	c7 44 24 04 8e 6c 10 	movl   $0x106c8e,0x4(%esp)
  100211:	00 
  100212:	c7 04 24 20 ad 10 00 	movl   $0x10ad20,(%esp)
  100219:	e8 12 3f 00 00       	call   104130 <initlock>

  devsw[CONSOLE].write = consolewrite;
  devsw[CONSOLE].read = consoleread;
  cons.locking = 1;

  picenable(IRQ_KBD);
  10021e:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
consoleinit(void)
{
  initlock(&cons.lock, "console");
  initlock(&input.lock, "input");

  devsw[CONSOLE].write = consolewrite;
  100225:	c7 05 8c b7 10 00 d0 	movl   $0x1003d0,0x10b78c
  10022c:	03 10 00 
  devsw[CONSOLE].read = consoleread;
  10022f:	c7 05 88 b7 10 00 20 	movl   $0x100620,0x10b788
  100236:	06 10 00 
  cons.locking = 1;
  100239:	c7 05 74 95 10 00 01 	movl   $0x1,0x109574
  100240:	00 00 00 

  picenable(IRQ_KBD);
  100243:	e8 e8 2a 00 00       	call   102d30 <picenable>
  ioapicenable(IRQ_KBD, 0);
  100248:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  10024f:	00 
  100250:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  100257:	e8 94 20 00 00       	call   1022f0 <ioapicenable>
}
  10025c:	c9                   	leave  
  10025d:	c3                   	ret    
  10025e:	66 90                	xchg   %ax,%ax

00100260 <consputc>:
  crt[pos] = ' ' | 0x0700;
}

void
consputc(int c)
{
  100260:	55                   	push   %ebp
  100261:	89 e5                	mov    %esp,%ebp
  100263:	57                   	push   %edi
  100264:	56                   	push   %esi
  100265:	89 c6                	mov    %eax,%esi
  100267:	53                   	push   %ebx
  100268:	83 ec 1c             	sub    $0x1c,%esp
  if(panicked){
  10026b:	83 3d 20 8d 10 00 00 	cmpl   $0x0,0x108d20
  100272:	74 03                	je     100277 <consputc+0x17>
}

static inline void
cli(void)
{
  asm volatile("cli");
  100274:	fa                   	cli    
  100275:	eb fe                	jmp    100275 <consputc+0x15>
    cli();
    for(;;)
      ;
  }

  if(c == BACKSPACE){
  100277:	3d 00 01 00 00       	cmp    $0x100,%eax
  10027c:	0f 84 a0 00 00 00    	je     100322 <consputc+0xc2>
    uartputc('\b'); uartputc(' '); uartputc('\b');
  } else
    uartputc(c);
  100282:	89 04 24             	mov    %eax,(%esp)
  100285:	e8 26 56 00 00       	call   1058b0 <uartputc>
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  10028a:	b9 d4 03 00 00       	mov    $0x3d4,%ecx
  10028f:	b8 0e 00 00 00       	mov    $0xe,%eax
  100294:	89 ca                	mov    %ecx,%edx
  100296:	ee                   	out    %al,(%dx)
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  100297:	bf d5 03 00 00       	mov    $0x3d5,%edi
  10029c:	89 fa                	mov    %edi,%edx
  10029e:	ec                   	in     (%dx),%al
{
  int pos;
  
  // Cursor position: col + 80*row.
  outb(CRTPORT, 14);
  pos = inb(CRTPORT+1) << 8;
  10029f:	0f b6 d8             	movzbl %al,%ebx
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  1002a2:	89 ca                	mov    %ecx,%edx
  1002a4:	c1 e3 08             	shl    $0x8,%ebx
  1002a7:	b8 0f 00 00 00       	mov    $0xf,%eax
  1002ac:	ee                   	out    %al,(%dx)
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  1002ad:	89 fa                	mov    %edi,%edx
  1002af:	ec                   	in     (%dx),%al
  outb(CRTPORT, 15);
  pos |= inb(CRTPORT+1);
  1002b0:	0f b6 c0             	movzbl %al,%eax
  1002b3:	09 c3                	or     %eax,%ebx

  if(c == '\n')
  1002b5:	83 fe 0a             	cmp    $0xa,%esi
  1002b8:	0f 84 ee 00 00 00    	je     1003ac <consputc+0x14c>
    pos += 80 - pos%80;
  else if(c == BACKSPACE){
  1002be:	81 fe 00 01 00 00    	cmp    $0x100,%esi
  1002c4:	0f 84 cb 00 00 00    	je     100395 <consputc+0x135>
    if(pos > 0) --pos;
  } else
    crt[pos++] = (c&0xff) | 0x0700;  // black on white
  1002ca:	66 81 e6 ff 00       	and    $0xff,%si
  1002cf:	66 81 ce 00 07       	or     $0x700,%si
  1002d4:	66 89 b4 1b 00 80 0b 	mov    %si,0xb8000(%ebx,%ebx,1)
  1002db:	00 
  1002dc:	83 c3 01             	add    $0x1,%ebx
  
  if((pos/80) >= 24){  // Scroll up.
  1002df:	81 fb 7f 07 00 00    	cmp    $0x77f,%ebx
  1002e5:	8d 8c 1b 00 80 0b 00 	lea    0xb8000(%ebx,%ebx,1),%ecx
  1002ec:	7f 5d                	jg     10034b <consputc+0xeb>
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  1002ee:	be d4 03 00 00       	mov    $0x3d4,%esi
  1002f3:	b8 0e 00 00 00       	mov    $0xe,%eax
  1002f8:	89 f2                	mov    %esi,%edx
  1002fa:	ee                   	out    %al,(%dx)
  1002fb:	bf d5 03 00 00       	mov    $0x3d5,%edi
  100300:	89 d8                	mov    %ebx,%eax
  100302:	c1 f8 08             	sar    $0x8,%eax
  100305:	89 fa                	mov    %edi,%edx
  100307:	ee                   	out    %al,(%dx)
  100308:	b8 0f 00 00 00       	mov    $0xf,%eax
  10030d:	89 f2                	mov    %esi,%edx
  10030f:	ee                   	out    %al,(%dx)
  100310:	89 d8                	mov    %ebx,%eax
  100312:	89 fa                	mov    %edi,%edx
  100314:	ee                   	out    %al,(%dx)
  
  outb(CRTPORT, 14);
  outb(CRTPORT+1, pos>>8);
  outb(CRTPORT, 15);
  outb(CRTPORT+1, pos);
  crt[pos] = ' ' | 0x0700;
  100315:	66 c7 01 20 07       	movw   $0x720,(%ecx)
  if(c == BACKSPACE){
    uartputc('\b'); uartputc(' '); uartputc('\b');
  } else
    uartputc(c);
  cgaputc(c);
}
  10031a:	83 c4 1c             	add    $0x1c,%esp
  10031d:	5b                   	pop    %ebx
  10031e:	5e                   	pop    %esi
  10031f:	5f                   	pop    %edi
  100320:	5d                   	pop    %ebp
  100321:	c3                   	ret    
    for(;;)
      ;
  }

  if(c == BACKSPACE){
    uartputc('\b'); uartputc(' '); uartputc('\b');
  100322:	c7 04 24 08 00 00 00 	movl   $0x8,(%esp)
  100329:	e8 82 55 00 00       	call   1058b0 <uartputc>
  10032e:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  100335:	e8 76 55 00 00       	call   1058b0 <uartputc>
  10033a:	c7 04 24 08 00 00 00 	movl   $0x8,(%esp)
  100341:	e8 6a 55 00 00       	call   1058b0 <uartputc>
  100346:	e9 3f ff ff ff       	jmp    10028a <consputc+0x2a>
  } else
    crt[pos++] = (c&0xff) | 0x0700;  // black on white
  
  if((pos/80) >= 24){  // Scroll up.
    memmove(crt, crt+80, sizeof(crt[0])*23*80);
    pos -= 80;
  10034b:	83 eb 50             	sub    $0x50,%ebx
    if(pos > 0) --pos;
  } else
    crt[pos++] = (c&0xff) | 0x0700;  // black on white
  
  if((pos/80) >= 24){  // Scroll up.
    memmove(crt, crt+80, sizeof(crt[0])*23*80);
  10034e:	c7 44 24 08 60 0e 00 	movl   $0xe60,0x8(%esp)
  100355:	00 
    pos -= 80;
    memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos));
  100356:	8d b4 1b 00 80 0b 00 	lea    0xb8000(%ebx,%ebx,1),%esi
    if(pos > 0) --pos;
  } else
    crt[pos++] = (c&0xff) | 0x0700;  // black on white
  
  if((pos/80) >= 24){  // Scroll up.
    memmove(crt, crt+80, sizeof(crt[0])*23*80);
  10035d:	c7 44 24 04 a0 80 0b 	movl   $0xb80a0,0x4(%esp)
  100364:	00 
  100365:	c7 04 24 00 80 0b 00 	movl   $0xb8000,(%esp)
  10036c:	e8 6f 40 00 00       	call   1043e0 <memmove>
    pos -= 80;
    memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos));
  100371:	b8 80 07 00 00       	mov    $0x780,%eax
  100376:	29 d8                	sub    %ebx,%eax
  100378:	01 c0                	add    %eax,%eax
  10037a:	89 44 24 08          	mov    %eax,0x8(%esp)
  10037e:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  100385:	00 
  100386:	89 34 24             	mov    %esi,(%esp)
  100389:	e8 d2 3f 00 00       	call   104360 <memset>
  outb(CRTPORT+1, pos);
  crt[pos] = ' ' | 0x0700;
}

void
consputc(int c)
  10038e:	89 f1                	mov    %esi,%ecx
  100390:	e9 59 ff ff ff       	jmp    1002ee <consputc+0x8e>
  pos |= inb(CRTPORT+1);

  if(c == '\n')
    pos += 80 - pos%80;
  else if(c == BACKSPACE){
    if(pos > 0) --pos;
  100395:	85 db                	test   %ebx,%ebx
  100397:	8d 8c 1b 00 80 0b 00 	lea    0xb8000(%ebx,%ebx,1),%ecx
  10039e:	0f 8e 4a ff ff ff    	jle    1002ee <consputc+0x8e>
  1003a4:	83 eb 01             	sub    $0x1,%ebx
  1003a7:	e9 33 ff ff ff       	jmp    1002df <consputc+0x7f>
  pos = inb(CRTPORT+1) << 8;
  outb(CRTPORT, 15);
  pos |= inb(CRTPORT+1);

  if(c == '\n')
    pos += 80 - pos%80;
  1003ac:	89 da                	mov    %ebx,%edx
  1003ae:	89 d8                	mov    %ebx,%eax
  1003b0:	b9 50 00 00 00       	mov    $0x50,%ecx
  1003b5:	83 c3 50             	add    $0x50,%ebx
  1003b8:	c1 fa 1f             	sar    $0x1f,%edx
  1003bb:	f7 f9                	idiv   %ecx
  1003bd:	29 d3                	sub    %edx,%ebx
  1003bf:	e9 1b ff ff ff       	jmp    1002df <consputc+0x7f>
  1003c4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  1003ca:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

001003d0 <consolewrite>:
  return target - n;
}

int
consolewrite(struct inode *ip, char *buf, int n)
{
  1003d0:	55                   	push   %ebp
  1003d1:	89 e5                	mov    %esp,%ebp
  1003d3:	57                   	push   %edi
  1003d4:	56                   	push   %esi
  1003d5:	53                   	push   %ebx
  1003d6:	83 ec 1c             	sub    $0x1c,%esp
  int i;

  iunlock(ip);
  1003d9:	8b 45 08             	mov    0x8(%ebp),%eax
  return target - n;
}

int
consolewrite(struct inode *ip, char *buf, int n)
{
  1003dc:	8b 75 10             	mov    0x10(%ebp),%esi
  1003df:	8b 7d 0c             	mov    0xc(%ebp),%edi
  int i;

  iunlock(ip);
  1003e2:	89 04 24             	mov    %eax,(%esp)
  1003e5:	e8 16 15 00 00       	call   101900 <iunlock>
  acquire(&cons.lock);
  1003ea:	c7 04 24 40 95 10 00 	movl   $0x109540,(%esp)
  1003f1:	e8 ca 3e 00 00       	call   1042c0 <acquire>
  for(i = 0; i < n; i++)
  1003f6:	85 f6                	test   %esi,%esi
  1003f8:	7e 16                	jle    100410 <consolewrite+0x40>
  1003fa:	31 db                	xor    %ebx,%ebx
  1003fc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    consputc(buf[i] & 0xff);
  100400:	0f b6 04 1f          	movzbl (%edi,%ebx,1),%eax
{
  int i;

  iunlock(ip);
  acquire(&cons.lock);
  for(i = 0; i < n; i++)
  100404:	83 c3 01             	add    $0x1,%ebx
    consputc(buf[i] & 0xff);
  100407:	e8 54 fe ff ff       	call   100260 <consputc>
{
  int i;

  iunlock(ip);
  acquire(&cons.lock);
  for(i = 0; i < n; i++)
  10040c:	39 de                	cmp    %ebx,%esi
  10040e:	7f f0                	jg     100400 <consolewrite+0x30>
    consputc(buf[i] & 0xff);
  release(&cons.lock);
  100410:	c7 04 24 40 95 10 00 	movl   $0x109540,(%esp)
  100417:	e8 54 3e 00 00       	call   104270 <release>
  ilock(ip);
  10041c:	8b 45 08             	mov    0x8(%ebp),%eax
  10041f:	89 04 24             	mov    %eax,(%esp)
  100422:	e8 19 19 00 00       	call   101d40 <ilock>

  return n;
}
  100427:	83 c4 1c             	add    $0x1c,%esp
  10042a:	89 f0                	mov    %esi,%eax
  10042c:	5b                   	pop    %ebx
  10042d:	5e                   	pop    %esi
  10042e:	5f                   	pop    %edi
  10042f:	5d                   	pop    %ebp
  100430:	c3                   	ret    
  100431:	eb 0d                	jmp    100440 <printint>
  100433:	90                   	nop
  100434:	90                   	nop
  100435:	90                   	nop
  100436:	90                   	nop
  100437:	90                   	nop
  100438:	90                   	nop
  100439:	90                   	nop
  10043a:	90                   	nop
  10043b:	90                   	nop
  10043c:	90                   	nop
  10043d:	90                   	nop
  10043e:	90                   	nop
  10043f:	90                   	nop

00100440 <printint>:
  int locking;
} cons;

static void
printint(int xx, int base, int sgn)
{
  100440:	55                   	push   %ebp
  100441:	89 e5                	mov    %esp,%ebp
  100443:	57                   	push   %edi
  100444:	56                   	push   %esi
  100445:	89 d6                	mov    %edx,%esi
  100447:	53                   	push   %ebx
  100448:	83 ec 1c             	sub    $0x1c,%esp
  static char digits[] = "0123456789abcdef";
  char buf[16];
  int i = 0, neg = 0;
  uint x;

  if(sgn && xx < 0){
  10044b:	85 c9                	test   %ecx,%ecx
  10044d:	74 04                	je     100453 <printint+0x13>
  10044f:	85 c0                	test   %eax,%eax
  100451:	78 55                	js     1004a8 <printint+0x68>
    neg = 1;
    x = -xx;
  } else
    x = xx;
  100453:	31 ff                	xor    %edi,%edi
  100455:	31 c9                	xor    %ecx,%ecx
  100457:	8d 5d d8             	lea    -0x28(%ebp),%ebx
  10045a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  do{
    buf[i++] = digits[x % base];
  100460:	31 d2                	xor    %edx,%edx
  100462:	f7 f6                	div    %esi
  100464:	0f b6 92 ae 6c 10 00 	movzbl 0x106cae(%edx),%edx
  10046b:	88 14 0b             	mov    %dl,(%ebx,%ecx,1)
  10046e:	83 c1 01             	add    $0x1,%ecx
  }while((x /= base) != 0);
  100471:	85 c0                	test   %eax,%eax
  100473:	75 eb                	jne    100460 <printint+0x20>
  if(neg)
  100475:	85 ff                	test   %edi,%edi
  100477:	74 08                	je     100481 <printint+0x41>
    buf[i++] = '-';
  100479:	c6 44 0d d8 2d       	movb   $0x2d,-0x28(%ebp,%ecx,1)
  10047e:	83 c1 01             	add    $0x1,%ecx

  while(--i >= 0)
  100481:	8d 71 ff             	lea    -0x1(%ecx),%esi
  100484:	01 f3                	add    %esi,%ebx
  100486:	66 90                	xchg   %ax,%ax
    consputc(buf[i]);
  100488:	0f be 03             	movsbl (%ebx),%eax
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
  10048b:	83 ee 01             	sub    $0x1,%esi
  10048e:	83 eb 01             	sub    $0x1,%ebx
    consputc(buf[i]);
  100491:	e8 ca fd ff ff       	call   100260 <consputc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
  100496:	83 fe ff             	cmp    $0xffffffff,%esi
  100499:	75 ed                	jne    100488 <printint+0x48>
    consputc(buf[i]);
}
  10049b:	83 c4 1c             	add    $0x1c,%esp
  10049e:	5b                   	pop    %ebx
  10049f:	5e                   	pop    %esi
  1004a0:	5f                   	pop    %edi
  1004a1:	5d                   	pop    %ebp
  1004a2:	c3                   	ret    
  1004a3:	90                   	nop
  1004a4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  int i = 0, neg = 0;
  uint x;

  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
  1004a8:	f7 d8                	neg    %eax
  1004aa:	bf 01 00 00 00       	mov    $0x1,%edi
  1004af:	eb a4                	jmp    100455 <printint+0x15>
  1004b1:	eb 0d                	jmp    1004c0 <cprintf>
  1004b3:	90                   	nop
  1004b4:	90                   	nop
  1004b5:	90                   	nop
  1004b6:	90                   	nop
  1004b7:	90                   	nop
  1004b8:	90                   	nop
  1004b9:	90                   	nop
  1004ba:	90                   	nop
  1004bb:	90                   	nop
  1004bc:	90                   	nop
  1004bd:	90                   	nop
  1004be:	90                   	nop
  1004bf:	90                   	nop

001004c0 <cprintf>:
}

// Print to the console. only understands %d, %x, %p, %s.
void
cprintf(char *fmt, ...)
{
  1004c0:	55                   	push   %ebp
  1004c1:	89 e5                	mov    %esp,%ebp
  1004c3:	57                   	push   %edi
  1004c4:	56                   	push   %esi
  1004c5:	53                   	push   %ebx
  1004c6:	83 ec 2c             	sub    $0x2c,%esp
  int i, c, state, locking;
  uint *argp;
  char *s;

  locking = cons.locking;
  1004c9:	8b 3d 74 95 10 00    	mov    0x109574,%edi
  if(locking)
  1004cf:	85 ff                	test   %edi,%edi
  1004d1:	0f 85 29 01 00 00    	jne    100600 <cprintf+0x140>
    acquire(&cons.lock);

  argp = (uint*)(void*)(&fmt + 1);
  state = 0;
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
  1004d7:	8b 4d 08             	mov    0x8(%ebp),%ecx
  1004da:	0f b6 01             	movzbl (%ecx),%eax
  1004dd:	85 c0                	test   %eax,%eax
  1004df:	0f 84 93 00 00 00    	je     100578 <cprintf+0xb8>

  locking = cons.locking;
  if(locking)
    acquire(&cons.lock);

  argp = (uint*)(void*)(&fmt + 1);
  1004e5:	8d 75 0c             	lea    0xc(%ebp),%esi
  1004e8:	31 db                	xor    %ebx,%ebx
  1004ea:	eb 3f                	jmp    10052b <cprintf+0x6b>
  1004ec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
      continue;
    }
    c = fmt[++i] & 0xff;
    if(c == 0)
      break;
    switch(c){
  1004f0:	83 fa 25             	cmp    $0x25,%edx
  1004f3:	0f 84 b7 00 00 00    	je     1005b0 <cprintf+0xf0>
  1004f9:	83 fa 64             	cmp    $0x64,%edx
  1004fc:	0f 84 8e 00 00 00    	je     100590 <cprintf+0xd0>
    case '%':
      consputc('%');
      break;
    default:
      // Print unknown % sequence to draw attention.
      consputc('%');
  100502:	b8 25 00 00 00       	mov    $0x25,%eax
  100507:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  10050a:	e8 51 fd ff ff       	call   100260 <consputc>
      consputc(c);
  10050f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  100512:	89 d0                	mov    %edx,%eax
  100514:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  100518:	e8 43 fd ff ff       	call   100260 <consputc>
  10051d:	8b 4d 08             	mov    0x8(%ebp),%ecx
  if(locking)
    acquire(&cons.lock);

  argp = (uint*)(void*)(&fmt + 1);
  state = 0;
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
  100520:	83 c3 01             	add    $0x1,%ebx
  100523:	0f b6 04 19          	movzbl (%ecx,%ebx,1),%eax
  100527:	85 c0                	test   %eax,%eax
  100529:	74 4d                	je     100578 <cprintf+0xb8>
    if(c != '%'){
  10052b:	83 f8 25             	cmp    $0x25,%eax
  10052e:	75 e8                	jne    100518 <cprintf+0x58>
      consputc(c);
      continue;
    }
    c = fmt[++i] & 0xff;
  100530:	83 c3 01             	add    $0x1,%ebx
  100533:	0f b6 14 19          	movzbl (%ecx,%ebx,1),%edx
    if(c == 0)
  100537:	85 d2                	test   %edx,%edx
  100539:	74 3d                	je     100578 <cprintf+0xb8>
      break;
    switch(c){
  10053b:	83 fa 70             	cmp    $0x70,%edx
  10053e:	74 12                	je     100552 <cprintf+0x92>
  100540:	7e ae                	jle    1004f0 <cprintf+0x30>
  100542:	83 fa 73             	cmp    $0x73,%edx
  100545:	8d 76 00             	lea    0x0(%esi),%esi
  100548:	74 7e                	je     1005c8 <cprintf+0x108>
  10054a:	83 fa 78             	cmp    $0x78,%edx
  10054d:	8d 76 00             	lea    0x0(%esi),%esi
  100550:	75 b0                	jne    100502 <cprintf+0x42>
    case 'd':
      printint(*argp++, 10, 1);
      break;
    case 'x':
    case 'p':
      printint(*argp++, 16, 0);
  100552:	8b 06                	mov    (%esi),%eax
  100554:	31 c9                	xor    %ecx,%ecx
  100556:	ba 10 00 00 00       	mov    $0x10,%edx
  if(locking)
    acquire(&cons.lock);

  argp = (uint*)(void*)(&fmt + 1);
  state = 0;
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
  10055b:	83 c3 01             	add    $0x1,%ebx
    case 'd':
      printint(*argp++, 10, 1);
      break;
    case 'x':
    case 'p':
      printint(*argp++, 16, 0);
  10055e:	83 c6 04             	add    $0x4,%esi
  100561:	e8 da fe ff ff       	call   100440 <printint>
  100566:	8b 4d 08             	mov    0x8(%ebp),%ecx
  if(locking)
    acquire(&cons.lock);

  argp = (uint*)(void*)(&fmt + 1);
  state = 0;
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
  100569:	0f b6 04 19          	movzbl (%ecx,%ebx,1),%eax
  10056d:	85 c0                	test   %eax,%eax
  10056f:	75 ba                	jne    10052b <cprintf+0x6b>
  100571:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
      consputc(c);
      break;
    }
  }

  if(locking)
  100578:	85 ff                	test   %edi,%edi
  10057a:	74 0c                	je     100588 <cprintf+0xc8>
    release(&cons.lock);
  10057c:	c7 04 24 40 95 10 00 	movl   $0x109540,(%esp)
  100583:	e8 e8 3c 00 00       	call   104270 <release>
}
  100588:	83 c4 2c             	add    $0x2c,%esp
  10058b:	5b                   	pop    %ebx
  10058c:	5e                   	pop    %esi
  10058d:	5f                   	pop    %edi
  10058e:	5d                   	pop    %ebp
  10058f:	c3                   	ret    
    c = fmt[++i] & 0xff;
    if(c == 0)
      break;
    switch(c){
    case 'd':
      printint(*argp++, 10, 1);
  100590:	8b 06                	mov    (%esi),%eax
  100592:	b9 01 00 00 00       	mov    $0x1,%ecx
  100597:	ba 0a 00 00 00       	mov    $0xa,%edx
  10059c:	83 c6 04             	add    $0x4,%esi
  10059f:	e8 9c fe ff ff       	call   100440 <printint>
  1005a4:	8b 4d 08             	mov    0x8(%ebp),%ecx
      break;
  1005a7:	e9 74 ff ff ff       	jmp    100520 <cprintf+0x60>
  1005ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
        s = "(null)";
      for(; *s; s++)
        consputc(*s);
      break;
    case '%':
      consputc('%');
  1005b0:	b8 25 00 00 00       	mov    $0x25,%eax
  1005b5:	e8 a6 fc ff ff       	call   100260 <consputc>
  1005ba:	8b 4d 08             	mov    0x8(%ebp),%ecx
      break;
  1005bd:	e9 5e ff ff ff       	jmp    100520 <cprintf+0x60>
  1005c2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    case 'x':
    case 'p':
      printint(*argp++, 16, 0);
      break;
    case 's':
      if((s = (char*)*argp++) == 0)
  1005c8:	8b 16                	mov    (%esi),%edx
  1005ca:	83 c6 04             	add    $0x4,%esi
  1005cd:	85 d2                	test   %edx,%edx
  1005cf:	74 47                	je     100618 <cprintf+0x158>
        s = "(null)";
      for(; *s; s++)
  1005d1:	0f b6 02             	movzbl (%edx),%eax
  1005d4:	84 c0                	test   %al,%al
  1005d6:	0f 84 44 ff ff ff    	je     100520 <cprintf+0x60>
  1005dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
        consputc(*s);
  1005e0:	0f be c0             	movsbl %al,%eax
  1005e3:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  1005e6:	e8 75 fc ff ff       	call   100260 <consputc>
      printint(*argp++, 16, 0);
      break;
    case 's':
      if((s = (char*)*argp++) == 0)
        s = "(null)";
      for(; *s; s++)
  1005eb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  1005ee:	83 c2 01             	add    $0x1,%edx
  1005f1:	0f b6 02             	movzbl (%edx),%eax
  1005f4:	84 c0                	test   %al,%al
  1005f6:	75 e8                	jne    1005e0 <cprintf+0x120>
  1005f8:	e9 20 ff ff ff       	jmp    10051d <cprintf+0x5d>
  1005fd:	8d 76 00             	lea    0x0(%esi),%esi
  uint *argp;
  char *s;

  locking = cons.locking;
  if(locking)
    acquire(&cons.lock);
  100600:	c7 04 24 40 95 10 00 	movl   $0x109540,(%esp)
  100607:	e8 b4 3c 00 00       	call   1042c0 <acquire>
  10060c:	e9 c6 fe ff ff       	jmp    1004d7 <cprintf+0x17>
  100611:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    case 'x':
    case 'p':
      printint(*argp++, 16, 0);
      break;
    case 's':
      if((s = (char*)*argp++) == 0)
  100618:	ba 94 6c 10 00       	mov    $0x106c94,%edx
  10061d:	eb b2                	jmp    1005d1 <cprintf+0x111>
  10061f:	90                   	nop

00100620 <consoleread>:
  release(&input.lock);
}

int
consoleread(struct inode *ip, char *dst, int n)
{
  100620:	55                   	push   %ebp
  100621:	89 e5                	mov    %esp,%ebp
  100623:	57                   	push   %edi
  100624:	56                   	push   %esi
  100625:	53                   	push   %ebx
  100626:	83 ec 3c             	sub    $0x3c,%esp
  100629:	8b 5d 10             	mov    0x10(%ebp),%ebx
  10062c:	8b 7d 08             	mov    0x8(%ebp),%edi
  10062f:	8b 75 0c             	mov    0xc(%ebp),%esi

  uint target;
  int c;

  iunlock(ip);
  100632:	89 3c 24             	mov    %edi,(%esp)
  100635:	e8 c6 12 00 00       	call   101900 <iunlock>
  target = n;
  10063a:	89 5d e4             	mov    %ebx,-0x1c(%ebp)
  acquire(&input.lock);
  10063d:	c7 04 24 20 ad 10 00 	movl   $0x10ad20,(%esp)
  100644:	e8 77 3c 00 00       	call   1042c0 <acquire>

  
  while(n > 0){
  100649:	85 db                	test   %ebx,%ebx
  10064b:	7f 2c                	jg     100679 <consoleread+0x59>
  10064d:	e9 c0 00 00 00       	jmp    100712 <consoleread+0xf2>
  100652:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    while(input.r == input.w){
      if(proc->killed){
  100658:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  10065e:	8b 40 24             	mov    0x24(%eax),%eax
  100661:	85 c0                	test   %eax,%eax
  100663:	75 5b                	jne    1006c0 <consoleread+0xa0>
        release(&input.lock);
        ilock(ip);
        return -1;
      }
      sleep(&input.r, &input.lock);
  100665:	c7 44 24 04 20 ad 10 	movl   $0x10ad20,0x4(%esp)
  10066c:	00 
  10066d:	c7 04 24 d4 ad 10 00 	movl   $0x10add4,(%esp)
  100674:	e8 07 2d 00 00       	call   103380 <sleep>
  target = n;
  acquire(&input.lock);

  
  while(n > 0){
    while(input.r == input.w){
  100679:	a1 d4 ad 10 00       	mov    0x10add4,%eax
  10067e:	3b 05 d8 ad 10 00    	cmp    0x10add8,%eax
  100684:	74 d2                	je     100658 <consoleread+0x38>
        ilock(ip);
        return -1;
      }
      sleep(&input.r, &input.lock);
    }
    c = input.buf[input.r++ % INPUT_BUF];
  100686:	89 c2                	mov    %eax,%edx
  100688:	83 e2 7f             	and    $0x7f,%edx
  10068b:	0f b6 8a 54 ad 10 00 	movzbl 0x10ad54(%edx),%ecx
  100692:	0f be d1             	movsbl %cl,%edx
  100695:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  100698:	8d 50 01             	lea    0x1(%eax),%edx
    if(c == C('D')){  // EOF
  10069b:	83 7d d4 04          	cmpl   $0x4,-0x2c(%ebp)
        ilock(ip);
        return -1;
      }
      sleep(&input.r, &input.lock);
    }
    c = input.buf[input.r++ % INPUT_BUF];
  10069f:	89 15 d4 ad 10 00    	mov    %edx,0x10add4
    if(c == C('D')){  // EOF
  1006a5:	74 3a                	je     1006e1 <consoleread+0xc1>
        // caller gets a 0-byte result.
        input.r--;
      }
      break;
    }
    *dst++ = c;
  1006a7:	88 0e                	mov    %cl,(%esi)

    --n;
  1006a9:	83 eb 01             	sub    $0x1,%ebx
    if(c == '\n')
  1006ac:	83 7d d4 0a          	cmpl   $0xa,-0x2c(%ebp)
  1006b0:	74 39                	je     1006eb <consoleread+0xcb>
  iunlock(ip);
  target = n;
  acquire(&input.lock);

  
  while(n > 0){
  1006b2:	85 db                	test   %ebx,%ebx
  1006b4:	7e 35                	jle    1006eb <consoleread+0xcb>
        // caller gets a 0-byte result.
        input.r--;
      }
      break;
    }
    *dst++ = c;
  1006b6:	83 c6 01             	add    $0x1,%esi
  1006b9:	eb be                	jmp    100679 <consoleread+0x59>
  1006bb:	90                   	nop
  1006bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

  
  while(n > 0){
    while(input.r == input.w){
      if(proc->killed){
        release(&input.lock);
  1006c0:	c7 04 24 20 ad 10 00 	movl   $0x10ad20,(%esp)
  1006c7:	e8 a4 3b 00 00       	call   104270 <release>
        ilock(ip);
  1006cc:	89 3c 24             	mov    %edi,(%esp)
  1006cf:	e8 6c 16 00 00       	call   101d40 <ilock>
  
  release(&input.lock);
  ilock(ip);

  return target - n;
}
  1006d4:	83 c4 3c             	add    $0x3c,%esp
  
  while(n > 0){
    while(input.r == input.w){
      if(proc->killed){
        release(&input.lock);
        ilock(ip);
  1006d7:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  
  release(&input.lock);
  ilock(ip);

  return target - n;
}
  1006dc:	5b                   	pop    %ebx
  1006dd:	5e                   	pop    %esi
  1006de:	5f                   	pop    %edi
  1006df:	5d                   	pop    %ebp
  1006e0:	c3                   	ret    
      }
      sleep(&input.r, &input.lock);
    }
    c = input.buf[input.r++ % INPUT_BUF];
    if(c == C('D')){  // EOF
      if(n < target){
  1006e1:	39 5d e4             	cmp    %ebx,-0x1c(%ebp)
  1006e4:	76 05                	jbe    1006eb <consoleread+0xcb>
        // Save ^D for next time, to make sure
        // caller gets a 0-byte result.
        input.r--;
  1006e6:	a3 d4 ad 10 00       	mov    %eax,0x10add4
  1006eb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1006ee:	29 d8                	sub    %ebx,%eax
      break;
  }
  

  
  release(&input.lock);
  1006f0:	c7 04 24 20 ad 10 00 	movl   $0x10ad20,(%esp)
  1006f7:	89 45 e0             	mov    %eax,-0x20(%ebp)
  1006fa:	e8 71 3b 00 00       	call   104270 <release>
  ilock(ip);
  1006ff:	89 3c 24             	mov    %edi,(%esp)
  100702:	e8 39 16 00 00       	call   101d40 <ilock>
  100707:	8b 45 e0             	mov    -0x20(%ebp),%eax

  return target - n;
}
  10070a:	83 c4 3c             	add    $0x3c,%esp
  10070d:	5b                   	pop    %ebx
  10070e:	5e                   	pop    %esi
  10070f:	5f                   	pop    %edi
  100710:	5d                   	pop    %ebp
  100711:	c3                   	ret    
  acquire(&input.lock);

  
  while(n > 0){
    while(input.r == input.w){
      if(proc->killed){
  100712:	31 c0                	xor    %eax,%eax
  100714:	eb da                	jmp    1006f0 <consoleread+0xd0>
  100716:	8d 76 00             	lea    0x0(%esi),%esi
  100719:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00100720 <consoleintr>:

#define C(x)  ((x)-'@')  // Control-x

void
consoleintr(int (*getc)(void))
{
  100720:	55                   	push   %ebp
  100721:	89 e5                	mov    %esp,%ebp
  100723:	57                   	push   %edi
  100724:	56                   	push   %esi
      
      
    default:
      if(c != 0 && input.e-input.r < INPUT_BUF){
        c = (c == '\r') ? '\n' : c;
        input.buf[input.e++ % INPUT_BUF] = c;
  100725:	be 50 ad 10 00       	mov    $0x10ad50,%esi

#define C(x)  ((x)-'@')  // Control-x

void
consoleintr(int (*getc)(void))
{
  10072a:	53                   	push   %ebx
  10072b:	83 ec 4c             	sub    $0x4c,%esp
  10072e:	8b 45 08             	mov    0x8(%ebp),%eax
  100731:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  int c;
  int i;

  acquire(&input.lock);
  100734:	c7 04 24 20 ad 10 00 	movl   $0x10ad20,(%esp)
  10073b:	e8 80 3b 00 00       	call   1042c0 <acquire>
  while((c = getc()) >= 0){
  100740:	ff 55 e4             	call   *-0x1c(%ebp)
  100743:	85 c0                	test   %eax,%eax
  100745:	89 c3                	mov    %eax,%ebx
  100747:	0f 88 21 01 00 00    	js     10086e <consoleintr+0x14e>
    switch(c){
  10074d:	83 fb 10             	cmp    $0x10,%ebx
  100750:	0f 84 9a 01 00 00    	je     1008f0 <consoleintr+0x1d0>
  100756:	0f 8f 2c 01 00 00    	jg     100888 <consoleintr+0x168>
  10075c:	83 fb 08             	cmp    $0x8,%ebx
  10075f:	90                   	nop
  100760:	0f 84 72 02 00 00    	je     1009d8 <consoleintr+0x2b8>
  100766:	83 fb 09             	cmp    $0x9,%ebx
  100769:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  100770:	0f 84 8a 01 00 00    	je     100900 <consoleintr+0x1e0>
      break;

      
      
    default:
      if(c != 0 && input.e-input.r < INPUT_BUF){
  100776:	85 db                	test   %ebx,%ebx
  100778:	74 c6                	je     100740 <consoleintr+0x20>
  10077a:	a1 dc ad 10 00       	mov    0x10addc,%eax
  10077f:	89 c2                	mov    %eax,%edx
  100781:	2b 15 d4 ad 10 00    	sub    0x10add4,%edx
  100787:	83 fa 7f             	cmp    $0x7f,%edx
  10078a:	77 b4                	ja     100740 <consoleintr+0x20>
        c = (c == '\r') ? '\n' : c;
  10078c:	83 fb 0d             	cmp    $0xd,%ebx
  10078f:	0f 84 78 02 00 00    	je     100a0d <consoleintr+0x2ed>
        input.buf[input.e++ % INPUT_BUF] = c;
  100795:	89 c2                	mov    %eax,%edx
  100797:	83 c0 01             	add    $0x1,%eax
  10079a:	83 e2 7f             	and    $0x7f,%edx
  10079d:	88 5c 16 04          	mov    %bl,0x4(%esi,%edx,1)
  1007a1:	a3 dc ad 10 00       	mov    %eax,0x10addc
        consputc(c);
  1007a6:	89 d8                	mov    %ebx,%eax
  1007a8:	e8 b3 fa ff ff       	call   100260 <consputc>
        if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){
  1007ad:	83 fb 04             	cmp    $0x4,%ebx
  1007b0:	0f 84 73 02 00 00    	je     100a29 <consoleintr+0x309>
  1007b6:	83 fb 0a             	cmp    $0xa,%ebx
  1007b9:	0f 84 6a 02 00 00    	je     100a29 <consoleintr+0x309>
  1007bf:	8b 15 d4 ad 10 00    	mov    0x10add4,%edx
  1007c5:	a1 dc ad 10 00       	mov    0x10addc,%eax
  1007ca:	83 ea 80             	sub    $0xffffff80,%edx
  1007cd:	39 d0                	cmp    %edx,%eax
  1007cf:	0f 85 6b ff ff ff    	jne    100740 <consoleintr+0x20>

//if we got \n that means that we got a complete command - now save it!
	  strncpy(commands[historyMarker], &input.buf[input.w],input.e-input.w);
  1007d5:	8b 15 d8 ad 10 00    	mov    0x10add8,%edx
  1007db:	29 d0                	sub    %edx,%eax
  1007dd:	81 c2 54 ad 10 00    	add    $0x10ad54,%edx
  1007e3:	89 44 24 08          	mov    %eax,0x8(%esp)
  1007e7:	a1 30 8d 10 00       	mov    0x108d30,%eax
  1007ec:	89 54 24 04          	mov    %edx,0x4(%esp)
  1007f0:	c1 e0 07             	shl    $0x7,%eax
  1007f3:	05 40 8d 10 00       	add    $0x108d40,%eax
  1007f8:	89 04 24             	mov    %eax,(%esp)
  1007fb:	e8 b0 3c 00 00       	call   1044b0 <strncpy>
	 
	  commands[historyMarker][input.e-input.w-1] = 0;
  100800:	8b 0d dc ad 10 00    	mov    0x10addc,%ecx
  100806:	a1 30 8d 10 00       	mov    0x108d30,%eax
  10080b:	8d 51 ff             	lea    -0x1(%ecx),%edx
  10080e:	2b 15 d8 ad 10 00    	sub    0x10add8,%edx
  100814:	89 c3                	mov    %eax,%ebx
  100816:	c1 e3 07             	shl    $0x7,%ebx
  100819:	c6 84 1a 40 8d 10 00 	movb   $0x0,0x108d40(%edx,%ebx,1)
  100820:	00 
	  numOfComm = numOfComm + 1; 
  100821:	8b 15 24 8d 10 00    	mov    0x108d24,%edx
  100827:	83 c2 01             	add    $0x1,%edx
	 
//raise flag if the commands data structure is now full
	  if (numOfComm == 16){
  10082a:	83 fa 10             	cmp    $0x10,%edx

//if we got \n that means that we got a complete command - now save it!
	  strncpy(commands[historyMarker], &input.buf[input.w],input.e-input.w);
	 
	  commands[historyMarker][input.e-input.w-1] = 0;
	  numOfComm = numOfComm + 1; 
  10082d:	89 15 24 8d 10 00    	mov    %edx,0x108d24
	 
//raise flag if the commands data structure is now full
	  if (numOfComm == 16){
  100833:	0f 84 18 02 00 00    	je     100a51 <consoleintr+0x331>
		  flag = 1;
	  }
	  arrowMarker = historyMarker;
	 
//set historyMarker for next time - where in the DS to put it
	  if (historyMarker ==15){
  100839:	83 f8 0f             	cmp    $0xf,%eax
	 
//raise flag if the commands data structure is now full
	  if (numOfComm == 16){
		  flag = 1;
	  }
	  arrowMarker = historyMarker;
  10083c:	a3 28 8d 10 00       	mov    %eax,0x108d28
	 
//set historyMarker for next time - where in the DS to put it
	  if (historyMarker ==15){
  100841:	0f 84 fb 01 00 00    	je     100a42 <consoleintr+0x322>
		  historyMarker = 0;
	  }
	  else{
		  historyMarker = historyMarker+1;
  100847:	83 c0 01             	add    $0x1,%eax
  10084a:	a3 30 8d 10 00       	mov    %eax,0x108d30
	  }

	  input.w = input.e;
  10084f:	89 0d d8 ad 10 00    	mov    %ecx,0x10add8
	  
          wakeup(&input.r);
  100855:	c7 04 24 d4 ad 10 00 	movl   $0x10add4,(%esp)
  10085c:	e8 ef 29 00 00       	call   103250 <wakeup>
{
  int c;
  int i;

  acquire(&input.lock);
  while((c = getc()) >= 0){
  100861:	ff 55 e4             	call   *-0x1c(%ebp)
  100864:	85 c0                	test   %eax,%eax
  100866:	89 c3                	mov    %eax,%ebx
  100868:	0f 89 df fe ff ff    	jns    10074d <consoleintr+0x2d>
        }
      }
      break;
    }
  }
  release(&input.lock);
  10086e:	c7 45 08 20 ad 10 00 	movl   $0x10ad20,0x8(%ebp)
}
  100875:	83 c4 4c             	add    $0x4c,%esp
  100878:	5b                   	pop    %ebx
  100879:	5e                   	pop    %esi
  10087a:	5f                   	pop    %edi
  10087b:	5d                   	pop    %ebp
        }
      }
      break;
    }
  }
  release(&input.lock);
  10087c:	e9 ef 39 00 00       	jmp    104270 <release>
  100881:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  int c;
  int i;

  acquire(&input.lock);
  while((c = getc()) >= 0){
    switch(c){
  100888:	83 fb 7f             	cmp    $0x7f,%ebx
  10088b:	0f 84 47 01 00 00    	je     1009d8 <consoleintr+0x2b8>
  100891:	81 fb e2 00 00 00    	cmp    $0xe2,%ebx
  100897:	74 67                	je     100900 <consoleintr+0x1e0>
  100899:	83 fb 15             	cmp    $0x15,%ebx
  10089c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1008a0:	0f 85 d0 fe ff ff    	jne    100776 <consoleintr+0x56>
    case C('P'):  // Process listing.
      procdump();
      break;
    case C('U'):  // Kill line.
      while(input.e != input.w &&
  1008a6:	a1 dc ad 10 00       	mov    0x10addc,%eax
  1008ab:	3b 05 d8 ad 10 00    	cmp    0x10add8,%eax
  1008b1:	0f 84 89 fe ff ff    	je     100740 <consoleintr+0x20>
  1008b7:	90                   	nop
            input.buf[(input.e-1) % INPUT_BUF] != '\n'){
  1008b8:	83 e8 01             	sub    $0x1,%eax
  1008bb:	89 c2                	mov    %eax,%edx
  1008bd:	83 e2 7f             	and    $0x7f,%edx
  1008c0:	80 ba 54 ad 10 00 0a 	cmpb   $0xa,0x10ad54(%edx)
  1008c7:	0f 84 73 fe ff ff    	je     100740 <consoleintr+0x20>
        input.e--;
  1008cd:	a3 dc ad 10 00       	mov    %eax,0x10addc
        consputc(BACKSPACE);
  1008d2:	b8 00 01 00 00       	mov    $0x100,%eax
  1008d7:	e8 84 f9 ff ff       	call   100260 <consputc>
    switch(c){
    case C('P'):  // Process listing.
      procdump();
      break;
    case C('U'):  // Kill line.
      while(input.e != input.w &&
  1008dc:	a1 dc ad 10 00       	mov    0x10addc,%eax
  1008e1:	3b 05 d8 ad 10 00    	cmp    0x10add8,%eax
  1008e7:	75 cf                	jne    1008b8 <consoleintr+0x198>
  1008e9:	e9 52 fe ff ff       	jmp    100740 <consoleintr+0x20>
  1008ee:	66 90                	xchg   %ax,%ax

  acquire(&input.lock);
  while((c = getc()) >= 0){
    switch(c){
    case C('P'):  // Process listing.
      procdump();
  1008f0:	e8 4b 37 00 00       	call   104040 <procdump>
  1008f5:	8d 76 00             	lea    0x0(%esi),%esi
      break;
  1008f8:	e9 43 fe ff ff       	jmp    100740 <consoleintr+0x20>
  1008fd:	8d 76 00             	lea    0x0(%esi),%esi
        input.e--;
        consputc(BACKSPACE);
      }
      break;
    case C('I'): case 226: // up arrow
	    if (numOfComm != 0)  {
  100900:	8b 15 24 8d 10 00    	mov    0x108d24,%edx
  100906:	85 d2                	test   %edx,%edx
  100908:	0f 84 32 fe ff ff    	je     100740 <consoleintr+0x20>
  10090e:	66 90                	xchg   %ax,%ax
  100910:	eb 26                	jmp    100938 <consoleintr+0x218>
  100912:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

//cleaning the current line
	    while(input.e != input.w &&
			 input.buf[(input.e-1) % INPUT_BUF] != '\n'){
  100918:	83 e8 01             	sub    $0x1,%eax
  10091b:	89 c2                	mov    %eax,%edx
  10091d:	83 e2 7f             	and    $0x7f,%edx
  100920:	80 ba 54 ad 10 00 0a 	cmpb   $0xa,0x10ad54(%edx)
  100927:	74 1c                	je     100945 <consoleintr+0x225>
		    input.e--;
  100929:	a3 dc ad 10 00       	mov    %eax,0x10addc
		    consputc(BACKSPACE);
  10092e:	b8 00 01 00 00       	mov    $0x100,%eax
  100933:	e8 28 f9 ff ff       	call   100260 <consputc>
      break;
    case C('I'): case 226: // up arrow
	    if (numOfComm != 0)  {

//cleaning the current line
	    while(input.e != input.w &&
  100938:	a1 dc ad 10 00       	mov    0x10addc,%eax
  10093d:	3b 05 d8 ad 10 00    	cmp    0x10add8,%eax
  100943:	75 d3                	jne    100918 <consoleintr+0x1f8>
  100945:	a1 28 8d 10 00       	mov    0x108d28,%eax
  10094a:	31 db                	xor    %ebx,%ebx
  10094c:	eb 35                	jmp    100983 <consoleintr+0x263>
  10094e:	66 90                	xchg   %ax,%ax

	    
//printing the last command
			 
	for (i=0; i<strlen(commands[arrowMarker]); i++){
		input.buf[(input.e++ % INPUT_BUF)] = commands[arrowMarker][i];
  100950:	8b 15 dc ad 10 00    	mov    0x10addc,%edx
  100956:	a1 28 8d 10 00       	mov    0x108d28,%eax
  10095b:	89 d1                	mov    %edx,%ecx
  10095d:	83 c2 01             	add    $0x1,%edx
  100960:	89 c7                	mov    %eax,%edi
  100962:	83 e1 7f             	and    $0x7f,%ecx
  100965:	c1 e7 07             	shl    $0x7,%edi
  100968:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  10096b:	0f b6 8c 3b 40 8d 10 	movzbl 0x108d40(%ebx,%edi,1),%ecx
  100972:	00 
			 }

	    
//printing the last command
			 
	for (i=0; i<strlen(commands[arrowMarker]); i++){
  100973:	83 c3 01             	add    $0x1,%ebx
		input.buf[(input.e++ % INPUT_BUF)] = commands[arrowMarker][i];
  100976:	8b 7d d4             	mov    -0x2c(%ebp),%edi
  100979:	88 4c 3e 04          	mov    %cl,0x4(%esi,%edi,1)
  10097d:	89 15 dc ad 10 00    	mov    %edx,0x10addc
			 }

	    
//printing the last command
			 
	for (i=0; i<strlen(commands[arrowMarker]); i++){
  100983:	c1 e0 07             	shl    $0x7,%eax
  100986:	05 40 8d 10 00       	add    $0x108d40,%eax
  10098b:	89 04 24             	mov    %eax,(%esp)
  10098e:	e8 ad 3b 00 00       	call   104540 <strlen>
  100993:	39 c3                	cmp    %eax,%ebx
  100995:	7c b9                	jl     100950 <consoleintr+0x230>
		input.buf[(input.e++ % INPUT_BUF)] = commands[arrowMarker][i];
		
	}	 
			 
			 
	    cprintf("%s",commands[arrowMarker]);
  100997:	a1 28 8d 10 00       	mov    0x108d28,%eax
  10099c:	c7 04 24 ff 71 10 00 	movl   $0x1071ff,(%esp)
  1009a3:	c1 e0 07             	shl    $0x7,%eax
  1009a6:	05 40 8d 10 00       	add    $0x108d40,%eax
  1009ab:	89 44 24 04          	mov    %eax,0x4(%esp)
  1009af:	e8 0c fb ff ff       	call   1004c0 <cprintf>
	    
//	    input.e = input.e + strlen(commands[arrowMarker]);
	    
//setting the arrowmarker to point at the right command for next time - cyclic
	    if (arrowMarker == 0){
  1009b4:	a1 28 8d 10 00       	mov    0x108d28,%eax
  1009b9:	85 c0                	test   %eax,%eax
  1009bb:	75 43                	jne    100a00 <consoleintr+0x2e0>
		if (flag==1){
  1009bd:	83 3d 2c 8d 10 00 01 	cmpl   $0x1,0x108d2c
  1009c4:	74 6d                	je     100a33 <consoleintr+0x313>
			arrowMarker = 15;
		}
		else {
			arrowMarker = numOfComm-1;
  1009c6:	a1 24 8d 10 00       	mov    0x108d24,%eax
  1009cb:	83 e8 01             	sub    $0x1,%eax
  1009ce:	a3 28 8d 10 00       	mov    %eax,0x108d28
  1009d3:	e9 68 fd ff ff       	jmp    100740 <consoleintr+0x20>
	    {arrowMarker = arrowMarker - 1;}
	   
	    }
    break;
    case C('H'): case '\x7f':  // Backspace
      if(input.e != input.w){
  1009d8:	a1 dc ad 10 00       	mov    0x10addc,%eax
  1009dd:	3b 05 d8 ad 10 00    	cmp    0x10add8,%eax
  1009e3:	0f 84 57 fd ff ff    	je     100740 <consoleintr+0x20>
        input.e--;
  1009e9:	83 e8 01             	sub    $0x1,%eax
  1009ec:	a3 dc ad 10 00       	mov    %eax,0x10addc
        consputc(BACKSPACE);
  1009f1:	b8 00 01 00 00       	mov    $0x100,%eax
  1009f6:	e8 65 f8 ff ff       	call   100260 <consputc>
  1009fb:	e9 40 fd ff ff       	jmp    100740 <consoleintr+0x20>
		else {
			arrowMarker = numOfComm-1;
		}    
	    }
	    else //if historyMarker !=0
	    {arrowMarker = arrowMarker - 1;}
  100a00:	83 e8 01             	sub    $0x1,%eax
  100a03:	a3 28 8d 10 00       	mov    %eax,0x108d28
  100a08:	e9 33 fd ff ff       	jmp    100740 <consoleintr+0x20>
      
      
    default:
      if(c != 0 && input.e-input.r < INPUT_BUF){
        c = (c == '\r') ? '\n' : c;
        input.buf[input.e++ % INPUT_BUF] = c;
  100a0d:	89 c2                	mov    %eax,%edx
  100a0f:	83 c0 01             	add    $0x1,%eax
  100a12:	83 e2 7f             	and    $0x7f,%edx
  100a15:	c6 44 16 04 0a       	movb   $0xa,0x4(%esi,%edx,1)
  100a1a:	a3 dc ad 10 00       	mov    %eax,0x10addc
        consputc(c);
  100a1f:	b8 0a 00 00 00       	mov    $0xa,%eax
  100a24:	e8 37 f8 ff ff       	call   100260 <consputc>
  100a29:	a1 dc ad 10 00       	mov    0x10addc,%eax
  100a2e:	e9 a2 fd ff ff       	jmp    1007d5 <consoleintr+0xb5>
//	    input.e = input.e + strlen(commands[arrowMarker]);
	    
//setting the arrowmarker to point at the right command for next time - cyclic
	    if (arrowMarker == 0){
		if (flag==1){
			arrowMarker = 15;
  100a33:	c7 05 28 8d 10 00 0f 	movl   $0xf,0x108d28
  100a3a:	00 00 00 
  100a3d:	e9 fe fc ff ff       	jmp    100740 <consoleintr+0x20>
	  }
	  arrowMarker = historyMarker;
	 
//set historyMarker for next time - where in the DS to put it
	  if (historyMarker ==15){
		  historyMarker = 0;
  100a42:	c7 05 30 8d 10 00 00 	movl   $0x0,0x108d30
  100a49:	00 00 00 
  100a4c:	e9 fe fd ff ff       	jmp    10084f <consoleintr+0x12f>
	  commands[historyMarker][input.e-input.w-1] = 0;
	  numOfComm = numOfComm + 1; 
	 
//raise flag if the commands data structure is now full
	  if (numOfComm == 16){
		  flag = 1;
  100a51:	c7 05 2c 8d 10 00 01 	movl   $0x1,0x108d2c
  100a58:	00 00 00 
  100a5b:	e9 d9 fd ff ff       	jmp    100839 <consoleintr+0x119>

00100a60 <panic>:
    release(&cons.lock);
}

void
panic(char *s)
{
  100a60:	55                   	push   %ebp
  100a61:	89 e5                	mov    %esp,%ebp
  100a63:	56                   	push   %esi
  100a64:	53                   	push   %ebx
  100a65:	83 ec 40             	sub    $0x40,%esp
}

static inline void
cli(void)
{
  asm volatile("cli");
  100a68:	fa                   	cli    
  int i;
  uint pcs[10];
  
  cli();
  cons.locking = 0;
  cprintf("cpu%d: panic: ", cpu->id);
  100a69:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  cprintf(s);
  cprintf("\n");
  getcallerpcs(&s, pcs);
  100a6f:	8d 75 d0             	lea    -0x30(%ebp),%esi
  100a72:	31 db                	xor    %ebx,%ebx
{
  int i;
  uint pcs[10];
  
  cli();
  cons.locking = 0;
  100a74:	c7 05 74 95 10 00 00 	movl   $0x0,0x109574
  100a7b:	00 00 00 
  cprintf("cpu%d: panic: ", cpu->id);
  100a7e:	0f b6 00             	movzbl (%eax),%eax
  100a81:	c7 04 24 9b 6c 10 00 	movl   $0x106c9b,(%esp)
  100a88:	89 44 24 04          	mov    %eax,0x4(%esp)
  100a8c:	e8 2f fa ff ff       	call   1004c0 <cprintf>
  cprintf(s);
  100a91:	8b 45 08             	mov    0x8(%ebp),%eax
  100a94:	89 04 24             	mov    %eax,(%esp)
  100a97:	e8 24 fa ff ff       	call   1004c0 <cprintf>
  cprintf("\n");
  100a9c:	c7 04 24 d6 70 10 00 	movl   $0x1070d6,(%esp)
  100aa3:	e8 18 fa ff ff       	call   1004c0 <cprintf>
  getcallerpcs(&s, pcs);
  100aa8:	8d 45 08             	lea    0x8(%ebp),%eax
  100aab:	89 74 24 04          	mov    %esi,0x4(%esp)
  100aaf:	89 04 24             	mov    %eax,(%esp)
  100ab2:	e8 99 36 00 00       	call   104150 <getcallerpcs>
  100ab7:	90                   	nop
  for(i=0; i<10; i++)
    cprintf(" %p", pcs[i]);
  100ab8:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  cons.locking = 0;
  cprintf("cpu%d: panic: ", cpu->id);
  cprintf(s);
  cprintf("\n");
  getcallerpcs(&s, pcs);
  for(i=0; i<10; i++)
  100abb:	83 c3 01             	add    $0x1,%ebx
    cprintf(" %p", pcs[i]);
  100abe:	c7 04 24 aa 6c 10 00 	movl   $0x106caa,(%esp)
  100ac5:	89 44 24 04          	mov    %eax,0x4(%esp)
  100ac9:	e8 f2 f9 ff ff       	call   1004c0 <cprintf>
  cons.locking = 0;
  cprintf("cpu%d: panic: ", cpu->id);
  cprintf(s);
  cprintf("\n");
  getcallerpcs(&s, pcs);
  for(i=0; i<10; i++)
  100ace:	83 fb 0a             	cmp    $0xa,%ebx
  100ad1:	75 e5                	jne    100ab8 <panic+0x58>
    cprintf(" %p", pcs[i]);
  panicked = 1; // freeze other CPU
  100ad3:	c7 05 20 8d 10 00 01 	movl   $0x1,0x108d20
  100ada:	00 00 00 
  100add:	eb fe                	jmp    100add <panic+0x7d>
  100adf:	90                   	nop

00100ae0 <exec>:
#include "x86.h"
#include "elf.h"

int
exec(char *path, char **argv)
{
  100ae0:	55                   	push   %ebp
  100ae1:	89 e5                	mov    %esp,%ebp
  100ae3:	57                   	push   %edi
  100ae4:	56                   	push   %esi
  100ae5:	53                   	push   %ebx
  100ae6:	81 ec ac 00 00 00    	sub    $0xac,%esp
  pde_t *pgdir, *oldpgdir;

  pgdir = 0;
  sz = 0;

  if((ip = namei(path)) == 0)
  100aec:	8b 45 08             	mov    0x8(%ebp),%eax
  100aef:	89 04 24             	mov    %eax,(%esp)
  100af2:	e8 e9 14 00 00       	call   101fe0 <namei>
  100af7:	89 c7                	mov    %eax,%edi
  100af9:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  100afe:	85 ff                	test   %edi,%edi
  100b00:	0f 84 1a 01 00 00    	je     100c20 <exec+0x140>
    return -1;
  ilock(ip);
  100b06:	89 3c 24             	mov    %edi,(%esp)
  100b09:	e8 32 12 00 00       	call   101d40 <ilock>

  // Check ELF header
  if(readi(ip, (char*)&elf, 0, sizeof(elf)) < sizeof(elf))
  100b0e:	8d 45 94             	lea    -0x6c(%ebp),%eax
  100b11:	c7 44 24 0c 34 00 00 	movl   $0x34,0xc(%esp)
  100b18:	00 
  100b19:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  100b20:	00 
  100b21:	89 44 24 04          	mov    %eax,0x4(%esp)
  100b25:	89 3c 24             	mov    %edi,(%esp)
  100b28:	e8 d3 09 00 00       	call   101500 <readi>
  100b2d:	83 f8 33             	cmp    $0x33,%eax
  100b30:	0f 86 dd 00 00 00    	jbe    100c13 <exec+0x133>
    goto bad;
  if(elf.magic != ELF_MAGIC)
  100b36:	81 7d 94 7f 45 4c 46 	cmpl   $0x464c457f,-0x6c(%ebp)
  100b3d:	0f 85 d0 00 00 00    	jne    100c13 <exec+0x133>
  100b43:	90                   	nop
  100b44:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    goto bad;

  if(!(pgdir = setupkvm()))
  100b48:	e8 e3 5a 00 00       	call   106630 <setupkvm>
  100b4d:	85 c0                	test   %eax,%eax
  100b4f:	89 45 80             	mov    %eax,-0x80(%ebp)
  100b52:	0f 84 bb 00 00 00    	je     100c13 <exec+0x133>
    goto bad;

  // Load program into memory.
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
  100b58:	66 83 7d c0 00       	cmpw   $0x0,-0x40(%ebp)
  100b5d:	8b 75 b0             	mov    -0x50(%ebp),%esi
  100b60:	0f 84 0d 03 00 00    	je     100e73 <exec+0x393>
  100b66:	c7 45 84 00 00 00 00 	movl   $0x0,-0x7c(%ebp)
  100b6d:	31 db                	xor    %ebx,%ebx
  100b6f:	eb 19                	jmp    100b8a <exec+0xaa>
  100b71:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  100b78:	0f b7 45 c0          	movzwl -0x40(%ebp),%eax
  100b7c:	83 c3 01             	add    $0x1,%ebx
  100b7f:	39 d8                	cmp    %ebx,%eax
  100b81:	0f 8e a9 00 00 00    	jle    100c30 <exec+0x150>
  100b87:	83 c6 20             	add    $0x20,%esi
    if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph))
  100b8a:	8d 55 c8             	lea    -0x38(%ebp),%edx
  100b8d:	c7 44 24 0c 20 00 00 	movl   $0x20,0xc(%esp)
  100b94:	00 
  100b95:	89 74 24 08          	mov    %esi,0x8(%esp)
  100b99:	89 54 24 04          	mov    %edx,0x4(%esp)
  100b9d:	89 3c 24             	mov    %edi,(%esp)
  100ba0:	e8 5b 09 00 00       	call   101500 <readi>
  100ba5:	83 f8 20             	cmp    $0x20,%eax
  100ba8:	75 5e                	jne    100c08 <exec+0x128>
      goto bad;
    if(ph.type != ELF_PROG_LOAD)
  100baa:	83 7d c8 01          	cmpl   $0x1,-0x38(%ebp)
  100bae:	75 c8                	jne    100b78 <exec+0x98>
      continue;
    if(ph.memsz < ph.filesz)
  100bb0:	8b 45 dc             	mov    -0x24(%ebp),%eax
  100bb3:	3b 45 d8             	cmp    -0x28(%ebp),%eax
  100bb6:	72 50                	jb     100c08 <exec+0x128>
      goto bad;
    if(!(sz = allocuvm(pgdir, sz, ph.va + ph.memsz)))
  100bb8:	03 45 d0             	add    -0x30(%ebp),%eax
  100bbb:	89 44 24 08          	mov    %eax,0x8(%esp)
  100bbf:	8b 4d 84             	mov    -0x7c(%ebp),%ecx
  100bc2:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  100bc6:	8b 45 80             	mov    -0x80(%ebp),%eax
  100bc9:	89 04 24             	mov    %eax,(%esp)
  100bcc:	e8 1f 5d 00 00       	call   1068f0 <allocuvm>
  100bd1:	85 c0                	test   %eax,%eax
  100bd3:	89 45 84             	mov    %eax,-0x7c(%ebp)
  100bd6:	74 30                	je     100c08 <exec+0x128>
      goto bad;
    if(!loaduvm(pgdir, (char *)ph.va, ip, ph.offset, ph.filesz))
  100bd8:	8b 45 d8             	mov    -0x28(%ebp),%eax
  100bdb:	89 44 24 10          	mov    %eax,0x10(%esp)
  100bdf:	8b 45 cc             	mov    -0x34(%ebp),%eax
  100be2:	89 7c 24 08          	mov    %edi,0x8(%esp)
  100be6:	89 44 24 0c          	mov    %eax,0xc(%esp)
  100bea:	8b 45 d0             	mov    -0x30(%ebp),%eax
  100bed:	89 44 24 04          	mov    %eax,0x4(%esp)
  100bf1:	8b 55 80             	mov    -0x80(%ebp),%edx
  100bf4:	89 14 24             	mov    %edx,(%esp)
  100bf7:	e8 c4 5d 00 00       	call   1069c0 <loaduvm>
  100bfc:	85 c0                	test   %eax,%eax
  100bfe:	0f 85 74 ff ff ff    	jne    100b78 <exec+0x98>
  100c04:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  freevm(oldpgdir);

  return 0;

 bad:
  if(pgdir) freevm(pgdir);
  100c08:	8b 45 80             	mov    -0x80(%ebp),%eax
  100c0b:	89 04 24             	mov    %eax,(%esp)
  100c0e:	e8 9d 5b 00 00       	call   1067b0 <freevm>
  iunlockput(ip);
  100c13:	89 3c 24             	mov    %edi,(%esp)
  100c16:	e8 35 10 00 00       	call   101c50 <iunlockput>
  100c1b:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  return -1;
}
  100c20:	81 c4 ac 00 00 00    	add    $0xac,%esp
  100c26:	5b                   	pop    %ebx
  100c27:	5e                   	pop    %esi
  100c28:	5f                   	pop    %edi
  100c29:	5d                   	pop    %ebp
  100c2a:	c3                   	ret    
  100c2b:	90                   	nop
  100c2c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

  if(!(pgdir = setupkvm()))
    goto bad;

  // Load program into memory.
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
  100c30:	8b 4d 84             	mov    -0x7c(%ebp),%ecx
  100c33:	81 c1 ff 0f 00 00    	add    $0xfff,%ecx
  100c39:	81 e1 00 f0 ff ff    	and    $0xfffff000,%ecx
  100c3f:	89 cb                	mov    %ecx,%ebx
  100c41:	89 4d 84             	mov    %ecx,-0x7c(%ebp)
  100c44:	81 c3 00 10 00 00    	add    $0x1000,%ebx
    if(!(sz = allocuvm(pgdir, sz, ph.va + ph.memsz)))
      goto bad;
    if(!loaduvm(pgdir, (char *)ph.va, ip, ph.offset, ph.filesz))
      goto bad;
  }
  iunlockput(ip);
  100c4a:	89 3c 24             	mov    %edi,(%esp)
  100c4d:	e8 fe 0f 00 00       	call   101c50 <iunlockput>

  // Allocate and initialize stack at sz
  sz = spbottom = PGROUNDUP(sz);
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
  100c52:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  100c56:	8b 45 84             	mov    -0x7c(%ebp),%eax
  100c59:	89 44 24 04          	mov    %eax,0x4(%esp)
  100c5d:	8b 55 80             	mov    -0x80(%ebp),%edx
  100c60:	89 14 24             	mov    %edx,(%esp)
  100c63:	e8 88 5c 00 00       	call   1068f0 <allocuvm>
  100c68:	85 c0                	test   %eax,%eax
  100c6a:	89 85 74 ff ff ff    	mov    %eax,-0x8c(%ebp)
  100c70:	74 96                	je     100c08 <exec+0x128>
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);
  100c72:	8b 4d 84             	mov    -0x7c(%ebp),%ecx
  100c75:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  100c79:	8b 45 80             	mov    -0x80(%ebp),%eax
  100c7c:	89 04 24             	mov    %eax,(%esp)
  100c7f:	e8 ec 58 00 00       	call   106570 <uva2ka>

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100c84:	8b 4d 0c             	mov    0xc(%ebp),%ecx

  // Allocate and initialize stack at sz
  sz = spbottom = PGROUNDUP(sz);
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);
  100c87:	89 85 7c ff ff ff    	mov    %eax,-0x84(%ebp)

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100c8d:	8b 11                	mov    (%ecx),%edx
  100c8f:	85 d2                	test   %edx,%edx
  100c91:	0f 84 ac 01 00 00    	je     100e43 <exec+0x363>
  100c97:	31 f6                	xor    %esi,%esi
  100c99:	31 db                	xor    %ebx,%ebx
  100c9b:	89 cf                	mov    %ecx,%edi
  100c9d:	8d 76 00             	lea    0x0(%esi),%esi
    arglen += strlen(argv[argc]) + 1;
  100ca0:	89 14 24             	mov    %edx,(%esp)
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100ca3:	83 c3 01             	add    $0x1,%ebx
    arglen += strlen(argv[argc]) + 1;
  100ca6:	e8 95 38 00 00       	call   104540 <strlen>
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100cab:	8b 14 9f             	mov    (%edi,%ebx,4),%edx
    arglen += strlen(argv[argc]) + 1;
  100cae:	01 f0                	add    %esi,%eax
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100cb0:	85 d2                	test   %edx,%edx
    arglen += strlen(argv[argc]) + 1;
  100cb2:	8d 70 01             	lea    0x1(%eax),%esi
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100cb5:	75 e9                	jne    100ca0 <exec+0x1c0>
    arglen += strlen(argv[argc]) + 1;
  arglen = (arglen+3) & ~3;

  sp = sz;
  argp = sz - arglen - 4*(argc+1);
  100cb7:	8b 8d 74 ff ff ff    	mov    -0x8c(%ebp),%ecx
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100cbd:	89 da                	mov    %ebx,%edx
  100cbf:	83 c0 04             	add    $0x4,%eax
  100cc2:	f7 d2                	not    %edx
    arglen += strlen(argv[argc]) + 1;
  arglen = (arglen+3) & ~3;

  sp = sz;
  argp = sz - arglen - 4*(argc+1);
  100cc4:	83 e0 fc             	and    $0xfffffffc,%eax
  100cc7:	89 9d 70 ff ff ff    	mov    %ebx,-0x90(%ebp)
  if(!(sz = allocuvm(pgdir, sz, sz + PGSIZE)))
    goto bad;
  mem = uva2ka(pgdir, (char *)spbottom);

  arglen = 0;
  for(argc=0; argv[argc]; argc++)
  100ccd:	89 df                	mov    %ebx,%edi
  100ccf:	83 ef 01             	sub    $0x1,%edi
    arglen += strlen(argv[argc]) + 1;
  arglen = (arglen+3) & ~3;

  sp = sz;
  argp = sz - arglen - 4*(argc+1);
  100cd2:	8d 14 91             	lea    (%ecx,%edx,4),%edx
  100cd5:	29 c2                	sub    %eax,%edx
  100cd7:	89 95 78 ff ff ff    	mov    %edx,-0x88(%ebp)

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  100cdd:	89 d1                	mov    %edx,%ecx
  100cdf:	8b 95 7c ff ff ff    	mov    -0x84(%ebp),%edx
  100ce5:	2b 4d 84             	sub    -0x7c(%ebp),%ecx
  100ce8:	8d 04 99             	lea    (%ecx,%ebx,4),%eax
  100ceb:	c7 04 10 00 00 00 00 	movl   $0x0,(%eax,%edx,1)
  100cf2:	8b 75 0c             	mov    0xc(%ebp),%esi
  100cf5:	8d 14 bd 00 00 00 00 	lea    0x0(,%edi,4),%edx
  100cfc:	8b 9d 74 ff ff ff    	mov    -0x8c(%ebp),%ebx
  100d02:	01 d6                	add    %edx,%esi
  100d04:	8d 14 11             	lea    (%ecx,%edx,1),%edx
  100d07:	03 95 7c ff ff ff    	add    -0x84(%ebp),%edx
  100d0d:	8d 76 00             	lea    0x0(%esi),%esi
  for(i=argc-1; i>=0; i--){
    len = strlen(argv[i]) + 1;
  100d10:	8b 06                	mov    (%esi),%eax
  sp = sz;
  argp = sz - arglen - 4*(argc+1);

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  for(i=argc-1; i>=0; i--){
  100d12:	83 ef 01             	sub    $0x1,%edi
    len = strlen(argv[i]) + 1;
  100d15:	89 04 24             	mov    %eax,(%esp)
  100d18:	89 95 6c ff ff ff    	mov    %edx,-0x94(%ebp)
  100d1e:	e8 1d 38 00 00       	call   104540 <strlen>
    sp -= len;
  100d23:	83 c0 01             	add    $0x1,%eax
  100d26:	29 c3                	sub    %eax,%ebx
    memmove(mem+sp-spbottom, argv[i], len);
  100d28:	89 44 24 08          	mov    %eax,0x8(%esp)
  100d2c:	8b 06                	mov    (%esi),%eax
  sp = sz;
  argp = sz - arglen - 4*(argc+1);

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  for(i=argc-1; i>=0; i--){
  100d2e:	83 ee 04             	sub    $0x4,%esi
    len = strlen(argv[i]) + 1;
    sp -= len;
    memmove(mem+sp-spbottom, argv[i], len);
  100d31:	89 44 24 04          	mov    %eax,0x4(%esp)
  100d35:	89 d8                	mov    %ebx,%eax
  100d37:	2b 45 84             	sub    -0x7c(%ebp),%eax
  100d3a:	03 85 7c ff ff ff    	add    -0x84(%ebp),%eax
  100d40:	89 04 24             	mov    %eax,(%esp)
  100d43:	e8 98 36 00 00       	call   1043e0 <memmove>
    *(uint*)(mem+argp-spbottom + 4*i) = sp;  // argv[i]
  100d48:	8b 95 6c ff ff ff    	mov    -0x94(%ebp),%edx
  100d4e:	89 1a                	mov    %ebx,(%edx)
  sp = sz;
  argp = sz - arglen - 4*(argc+1);

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  for(i=argc-1; i>=0; i--){
  100d50:	83 ea 04             	sub    $0x4,%edx
  100d53:	83 ff ff             	cmp    $0xffffffff,%edi
  100d56:	75 b8                	jne    100d10 <exec+0x230>
    *(uint*)(mem+argp-spbottom + 4*i) = sp;  // argv[i]
  }

  // Stack frame for main(argc, argv), below arguments.
  sp = argp;
  sp -= 4;
  100d58:	8b 85 78 ff ff ff    	mov    -0x88(%ebp),%eax
  *(uint*)(mem+sp-spbottom) = argp;
  100d5e:	8b 95 78 ff ff ff    	mov    -0x88(%ebp),%edx
  100d64:	8b 8d 7c ff ff ff    	mov    -0x84(%ebp),%ecx
    *(uint*)(mem+argp-spbottom + 4*i) = sp;  // argv[i]
  }

  // Stack frame for main(argc, argv), below arguments.
  sp = argp;
  sp -= 4;
  100d6a:	83 e8 04             	sub    $0x4,%eax
  *(uint*)(mem+sp-spbottom) = argp;
  100d6d:	2b 45 84             	sub    -0x7c(%ebp),%eax
  100d70:	89 14 01             	mov    %edx,(%ecx,%eax,1)
  sp -= 4;
  100d73:	89 d0                	mov    %edx,%eax
  *(uint*)(mem+sp-spbottom) = argc;
  100d75:	8b 95 70 ff ff ff    	mov    -0x90(%ebp),%edx

  // Stack frame for main(argc, argv), below arguments.
  sp = argp;
  sp -= 4;
  *(uint*)(mem+sp-spbottom) = argp;
  sp -= 4;
  100d7b:	83 e8 08             	sub    $0x8,%eax
  *(uint*)(mem+sp-spbottom) = argc;
  100d7e:	2b 45 84             	sub    -0x7c(%ebp),%eax
  100d81:	89 14 01             	mov    %edx,(%ecx,%eax,1)
  sp -= 4;
  100d84:	8b 9d 78 ff ff ff    	mov    -0x88(%ebp),%ebx
  100d8a:	83 eb 0c             	sub    $0xc,%ebx
  *(uint*)(mem+sp-spbottom) = 0xffffffff;   // fake return pc
  100d8d:	89 d8                	mov    %ebx,%eax
  100d8f:	2b 45 84             	sub    -0x7c(%ebp),%eax
  100d92:	c7 04 01 ff ff ff ff 	movl   $0xffffffff,(%ecx,%eax,1)

  // Save program name for debugging.
  for(last=s=path; *s; s++)
  100d99:	8b 4d 08             	mov    0x8(%ebp),%ecx
  100d9c:	0f b6 11             	movzbl (%ecx),%edx
  100d9f:	84 d2                	test   %dl,%dl
  100da1:	74 28                	je     100dcb <exec+0x2eb>
  100da3:	89 c8                	mov    %ecx,%eax
  100da5:	83 c0 01             	add    $0x1,%eax
  100da8:	eb 10                	jmp    100dba <exec+0x2da>
  100daa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  100db0:	0f b6 10             	movzbl (%eax),%edx
  100db3:	83 c0 01             	add    $0x1,%eax
  100db6:	84 d2                	test   %dl,%dl
  100db8:	74 11                	je     100dcb <exec+0x2eb>
    if(*s == '/')
  100dba:	80 fa 2f             	cmp    $0x2f,%dl
  100dbd:	75 f1                	jne    100db0 <exec+0x2d0>
  *(uint*)(mem+sp-spbottom) = argc;
  sp -= 4;
  *(uint*)(mem+sp-spbottom) = 0xffffffff;   // fake return pc

  // Save program name for debugging.
  for(last=s=path; *s; s++)
  100dbf:	0f b6 10             	movzbl (%eax),%edx
    if(*s == '/')
  100dc2:	89 c1                	mov    %eax,%ecx
  *(uint*)(mem+sp-spbottom) = argc;
  sp -= 4;
  *(uint*)(mem+sp-spbottom) = 0xffffffff;   // fake return pc

  // Save program name for debugging.
  for(last=s=path; *s; s++)
  100dc4:	83 c0 01             	add    $0x1,%eax
  100dc7:	84 d2                	test   %dl,%dl
  100dc9:	75 ef                	jne    100dba <exec+0x2da>
    if(*s == '/')
      last = s+1;
  safestrcpy(proc->name, last, sizeof(proc->name));
  100dcb:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  100dd1:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  100dd5:	c7 44 24 08 10 00 00 	movl   $0x10,0x8(%esp)
  100ddc:	00 
  100ddd:	83 c0 6c             	add    $0x6c,%eax
  100de0:	89 04 24             	mov    %eax,(%esp)
  100de3:	e8 18 37 00 00       	call   104500 <safestrcpy>

  // Commit to the user image.
  oldpgdir = proc->pgdir;
  proc->pgdir = pgdir;
  100de8:	8b 55 80             	mov    -0x80(%ebp),%edx
    if(*s == '/')
      last = s+1;
  safestrcpy(proc->name, last, sizeof(proc->name));

  // Commit to the user image.
  oldpgdir = proc->pgdir;
  100deb:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  100df1:	8b 70 04             	mov    0x4(%eax),%esi
  proc->pgdir = pgdir;
  100df4:	89 50 04             	mov    %edx,0x4(%eax)
  proc->sz = sz;
  100df7:	8b 8d 74 ff ff ff    	mov    -0x8c(%ebp),%ecx
  100dfd:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  100e03:	89 08                	mov    %ecx,(%eax)
  proc->tf->eip = elf.entry;  // main
  100e05:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  100e0b:	8b 55 ac             	mov    -0x54(%ebp),%edx
  100e0e:	8b 40 18             	mov    0x18(%eax),%eax
  100e11:	89 50 38             	mov    %edx,0x38(%eax)
  proc->tf->esp = sp;
  100e14:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  100e1a:	8b 40 18             	mov    0x18(%eax),%eax
  100e1d:	89 58 44             	mov    %ebx,0x44(%eax)

  switchuvm(proc); 
  100e20:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  100e26:	89 04 24             	mov    %eax,(%esp)
  100e29:	e8 52 5c 00 00       	call   106a80 <switchuvm>

  freevm(oldpgdir);
  100e2e:	89 34 24             	mov    %esi,(%esp)
  100e31:	e8 7a 59 00 00       	call   1067b0 <freevm>

 bad:
  if(pgdir) freevm(pgdir);
  iunlockput(ip);
  return -1;
}
  100e36:	81 c4 ac 00 00 00    	add    $0xac,%esp
  proc->tf->eip = elf.entry;  // main
  proc->tf->esp = sp;

  switchuvm(proc); 

  freevm(oldpgdir);
  100e3c:	31 c0                	xor    %eax,%eax

 bad:
  if(pgdir) freevm(pgdir);
  iunlockput(ip);
  return -1;
}
  100e3e:	5b                   	pop    %ebx
  100e3f:	5e                   	pop    %esi
  100e40:	5f                   	pop    %edi
  100e41:	5d                   	pop    %ebp
  100e42:	c3                   	ret    
  for(argc=0; argv[argc]; argc++)
    arglen += strlen(argv[argc]) + 1;
  arglen = (arglen+3) & ~3;

  sp = sz;
  argp = sz - arglen - 4*(argc+1);
  100e43:	8b 95 74 ff ff ff    	mov    -0x8c(%ebp),%edx

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  100e49:	8b 8d 7c ff ff ff    	mov    -0x84(%ebp),%ecx
  for(argc=0; argv[argc]; argc++)
    arglen += strlen(argv[argc]) + 1;
  arglen = (arglen+3) & ~3;

  sp = sz;
  argp = sz - arglen - 4*(argc+1);
  100e4f:	83 ea 04             	sub    $0x4,%edx

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  100e52:	89 d0                	mov    %edx,%eax
  100e54:	2b 45 84             	sub    -0x7c(%ebp),%eax
  for(argc=0; argv[argc]; argc++)
    arglen += strlen(argv[argc]) + 1;
  arglen = (arglen+3) & ~3;

  sp = sz;
  argp = sz - arglen - 4*(argc+1);
  100e57:	89 95 78 ff ff ff    	mov    %edx,-0x88(%ebp)

  // Copy argv strings and pointers to stack.
  *(uint*)(mem+argp-spbottom + 4*argc) = 0;  // argv[argc]
  100e5d:	c7 04 01 00 00 00 00 	movl   $0x0,(%ecx,%eax,1)
  100e64:	c7 85 70 ff ff ff 00 	movl   $0x0,-0x90(%ebp)
  100e6b:	00 00 00 
  100e6e:	e9 e5 fe ff ff       	jmp    100d58 <exec+0x278>

  if(!(pgdir = setupkvm()))
    goto bad;

  // Load program into memory.
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
  100e73:	bb 00 10 00 00       	mov    $0x1000,%ebx
  100e78:	c7 45 84 00 00 00 00 	movl   $0x0,-0x7c(%ebp)
  100e7f:	e9 c6 fd ff ff       	jmp    100c4a <exec+0x16a>
  100e84:	90                   	nop
  100e85:	90                   	nop
  100e86:	90                   	nop
  100e87:	90                   	nop
  100e88:	90                   	nop
  100e89:	90                   	nop
  100e8a:	90                   	nop
  100e8b:	90                   	nop
  100e8c:	90                   	nop
  100e8d:	90                   	nop
  100e8e:	90                   	nop
  100e8f:	90                   	nop

00100e90 <filewrite>:
}

// Write to file f.  Addr is kernel address.
int
filewrite(struct file *f, char *addr, int n)
{
  100e90:	55                   	push   %ebp
  100e91:	89 e5                	mov    %esp,%ebp
  100e93:	83 ec 38             	sub    $0x38,%esp
  100e96:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  100e99:	8b 5d 08             	mov    0x8(%ebp),%ebx
  100e9c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  100e9f:	8b 75 0c             	mov    0xc(%ebp),%esi
  100ea2:	89 7d fc             	mov    %edi,-0x4(%ebp)
  100ea5:	8b 7d 10             	mov    0x10(%ebp),%edi
  int r;

  if(f->writable == 0)
  100ea8:	80 7b 09 00          	cmpb   $0x0,0x9(%ebx)
  100eac:	74 5a                	je     100f08 <filewrite+0x78>
    return -1;
  if(f->type == FD_PIPE)
  100eae:	8b 03                	mov    (%ebx),%eax
  100eb0:	83 f8 01             	cmp    $0x1,%eax
  100eb3:	74 5b                	je     100f10 <filewrite+0x80>
    return pipewrite(f->pipe, addr, n);
  if(f->type == FD_INODE){
  100eb5:	83 f8 02             	cmp    $0x2,%eax
  100eb8:	75 6d                	jne    100f27 <filewrite+0x97>
    ilock(f->ip);
  100eba:	8b 43 10             	mov    0x10(%ebx),%eax
  100ebd:	89 04 24             	mov    %eax,(%esp)
  100ec0:	e8 7b 0e 00 00       	call   101d40 <ilock>
    if((r = writei(f->ip, addr, f->off, n)) > 0)
  100ec5:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  100ec9:	8b 43 14             	mov    0x14(%ebx),%eax
  100ecc:	89 74 24 04          	mov    %esi,0x4(%esp)
  100ed0:	89 44 24 08          	mov    %eax,0x8(%esp)
  100ed4:	8b 43 10             	mov    0x10(%ebx),%eax
  100ed7:	89 04 24             	mov    %eax,(%esp)
  100eda:	e8 b1 07 00 00       	call   101690 <writei>
  100edf:	85 c0                	test   %eax,%eax
  100ee1:	7e 03                	jle    100ee6 <filewrite+0x56>
      f->off += r;
  100ee3:	01 43 14             	add    %eax,0x14(%ebx)
    iunlock(f->ip);
  100ee6:	8b 53 10             	mov    0x10(%ebx),%edx
  100ee9:	89 14 24             	mov    %edx,(%esp)
  100eec:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  100eef:	e8 0c 0a 00 00       	call   101900 <iunlock>
    return r;
  100ef4:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  }
  panic("filewrite");
}
  100ef7:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  100efa:	8b 75 f8             	mov    -0x8(%ebp),%esi
  100efd:	8b 7d fc             	mov    -0x4(%ebp),%edi
  100f00:	89 ec                	mov    %ebp,%esp
  100f02:	5d                   	pop    %ebp
  100f03:	c3                   	ret    
  100f04:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    if((r = writei(f->ip, addr, f->off, n)) > 0)
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("filewrite");
  100f08:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  100f0d:	eb e8                	jmp    100ef7 <filewrite+0x67>
  100f0f:	90                   	nop
  int r;

  if(f->writable == 0)
    return -1;
  if(f->type == FD_PIPE)
    return pipewrite(f->pipe, addr, n);
  100f10:	8b 43 0c             	mov    0xc(%ebx),%eax
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("filewrite");
}
  100f13:	8b 75 f8             	mov    -0x8(%ebp),%esi
  100f16:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  100f19:	8b 7d fc             	mov    -0x4(%ebp),%edi
  int r;

  if(f->writable == 0)
    return -1;
  if(f->type == FD_PIPE)
    return pipewrite(f->pipe, addr, n);
  100f1c:	89 45 08             	mov    %eax,0x8(%ebp)
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("filewrite");
}
  100f1f:	89 ec                	mov    %ebp,%esp
  100f21:	5d                   	pop    %ebp
  int r;

  if(f->writable == 0)
    return -1;
  if(f->type == FD_PIPE)
    return pipewrite(f->pipe, addr, n);
  100f22:	e9 d9 1f 00 00       	jmp    102f00 <pipewrite>
    if((r = writei(f->ip, addr, f->off, n)) > 0)
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("filewrite");
  100f27:	c7 04 24 bf 6c 10 00 	movl   $0x106cbf,(%esp)
  100f2e:	e8 2d fb ff ff       	call   100a60 <panic>
  100f33:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  100f39:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00100f40 <fileread>:
}

// Read from file f.  Addr is kernel address.
int
fileread(struct file *f, char *addr, int n)
{
  100f40:	55                   	push   %ebp
  100f41:	89 e5                	mov    %esp,%ebp
  100f43:	83 ec 38             	sub    $0x38,%esp
  100f46:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  100f49:	8b 5d 08             	mov    0x8(%ebp),%ebx
  100f4c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  100f4f:	8b 75 0c             	mov    0xc(%ebp),%esi
  100f52:	89 7d fc             	mov    %edi,-0x4(%ebp)
  100f55:	8b 7d 10             	mov    0x10(%ebp),%edi
  int r;

  if(f->readable == 0)
  100f58:	80 7b 08 00          	cmpb   $0x0,0x8(%ebx)
  100f5c:	74 5a                	je     100fb8 <fileread+0x78>
    return -1;
  if(f->type == FD_PIPE)
  100f5e:	8b 03                	mov    (%ebx),%eax
  100f60:	83 f8 01             	cmp    $0x1,%eax
  100f63:	74 5b                	je     100fc0 <fileread+0x80>
    return piperead(f->pipe, addr, n);
  if(f->type == FD_INODE){
  100f65:	83 f8 02             	cmp    $0x2,%eax
  100f68:	75 6d                	jne    100fd7 <fileread+0x97>
    ilock(f->ip);
  100f6a:	8b 43 10             	mov    0x10(%ebx),%eax
  100f6d:	89 04 24             	mov    %eax,(%esp)
  100f70:	e8 cb 0d 00 00       	call   101d40 <ilock>
    if((r = readi(f->ip, addr, f->off, n)) > 0)
  100f75:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  100f79:	8b 43 14             	mov    0x14(%ebx),%eax
  100f7c:	89 74 24 04          	mov    %esi,0x4(%esp)
  100f80:	89 44 24 08          	mov    %eax,0x8(%esp)
  100f84:	8b 43 10             	mov    0x10(%ebx),%eax
  100f87:	89 04 24             	mov    %eax,(%esp)
  100f8a:	e8 71 05 00 00       	call   101500 <readi>
  100f8f:	85 c0                	test   %eax,%eax
  100f91:	7e 03                	jle    100f96 <fileread+0x56>
      f->off += r;
  100f93:	01 43 14             	add    %eax,0x14(%ebx)
    iunlock(f->ip);
  100f96:	8b 53 10             	mov    0x10(%ebx),%edx
  100f99:	89 14 24             	mov    %edx,(%esp)
  100f9c:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  100f9f:	e8 5c 09 00 00       	call   101900 <iunlock>
    return r;
  100fa4:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  }
  panic("fileread");
}
  100fa7:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  100faa:	8b 75 f8             	mov    -0x8(%ebp),%esi
  100fad:	8b 7d fc             	mov    -0x4(%ebp),%edi
  100fb0:	89 ec                	mov    %ebp,%esp
  100fb2:	5d                   	pop    %ebp
  100fb3:	c3                   	ret    
  100fb4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    if((r = readi(f->ip, addr, f->off, n)) > 0)
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("fileread");
  100fb8:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  100fbd:	eb e8                	jmp    100fa7 <fileread+0x67>
  100fbf:	90                   	nop
  int r;

  if(f->readable == 0)
    return -1;
  if(f->type == FD_PIPE)
    return piperead(f->pipe, addr, n);
  100fc0:	8b 43 0c             	mov    0xc(%ebx),%eax
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("fileread");
}
  100fc3:	8b 75 f8             	mov    -0x8(%ebp),%esi
  100fc6:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  100fc9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  int r;

  if(f->readable == 0)
    return -1;
  if(f->type == FD_PIPE)
    return piperead(f->pipe, addr, n);
  100fcc:	89 45 08             	mov    %eax,0x8(%ebp)
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("fileread");
}
  100fcf:	89 ec                	mov    %ebp,%esp
  100fd1:	5d                   	pop    %ebp
  int r;

  if(f->readable == 0)
    return -1;
  if(f->type == FD_PIPE)
    return piperead(f->pipe, addr, n);
  100fd2:	e9 29 1e 00 00       	jmp    102e00 <piperead>
    if((r = readi(f->ip, addr, f->off, n)) > 0)
      f->off += r;
    iunlock(f->ip);
    return r;
  }
  panic("fileread");
  100fd7:	c7 04 24 c9 6c 10 00 	movl   $0x106cc9,(%esp)
  100fde:	e8 7d fa ff ff       	call   100a60 <panic>
  100fe3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  100fe9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00100ff0 <filestat>:
}

// Get metadata about file f.
int
filestat(struct file *f, struct stat *st)
{
  100ff0:	55                   	push   %ebp
  if(f->type == FD_INODE){
  100ff1:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}

// Get metadata about file f.
int
filestat(struct file *f, struct stat *st)
{
  100ff6:	89 e5                	mov    %esp,%ebp
  100ff8:	53                   	push   %ebx
  100ff9:	83 ec 14             	sub    $0x14,%esp
  100ffc:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if(f->type == FD_INODE){
  100fff:	83 3b 02             	cmpl   $0x2,(%ebx)
  101002:	74 0c                	je     101010 <filestat+0x20>
    stati(f->ip, st);
    iunlock(f->ip);
    return 0;
  }
  return -1;
}
  101004:	83 c4 14             	add    $0x14,%esp
  101007:	5b                   	pop    %ebx
  101008:	5d                   	pop    %ebp
  101009:	c3                   	ret    
  10100a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
// Get metadata about file f.
int
filestat(struct file *f, struct stat *st)
{
  if(f->type == FD_INODE){
    ilock(f->ip);
  101010:	8b 43 10             	mov    0x10(%ebx),%eax
  101013:	89 04 24             	mov    %eax,(%esp)
  101016:	e8 25 0d 00 00       	call   101d40 <ilock>
    stati(f->ip, st);
  10101b:	8b 45 0c             	mov    0xc(%ebp),%eax
  10101e:	89 44 24 04          	mov    %eax,0x4(%esp)
  101022:	8b 43 10             	mov    0x10(%ebx),%eax
  101025:	89 04 24             	mov    %eax,(%esp)
  101028:	e8 e3 01 00 00       	call   101210 <stati>
    iunlock(f->ip);
  10102d:	8b 43 10             	mov    0x10(%ebx),%eax
  101030:	89 04 24             	mov    %eax,(%esp)
  101033:	e8 c8 08 00 00       	call   101900 <iunlock>
    return 0;
  }
  return -1;
}
  101038:	83 c4 14             	add    $0x14,%esp
filestat(struct file *f, struct stat *st)
{
  if(f->type == FD_INODE){
    ilock(f->ip);
    stati(f->ip, st);
    iunlock(f->ip);
  10103b:	31 c0                	xor    %eax,%eax
    return 0;
  }
  return -1;
}
  10103d:	5b                   	pop    %ebx
  10103e:	5d                   	pop    %ebp
  10103f:	c3                   	ret    

00101040 <filedup>:
}

// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
  101040:	55                   	push   %ebp
  101041:	89 e5                	mov    %esp,%ebp
  101043:	53                   	push   %ebx
  101044:	83 ec 14             	sub    $0x14,%esp
  101047:	8b 5d 08             	mov    0x8(%ebp),%ebx
  acquire(&ftable.lock);
  10104a:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  101051:	e8 6a 32 00 00       	call   1042c0 <acquire>
  if(f->ref < 1)
  101056:	8b 43 04             	mov    0x4(%ebx),%eax
  101059:	85 c0                	test   %eax,%eax
  10105b:	7e 1a                	jle    101077 <filedup+0x37>
    panic("filedup");
  f->ref++;
  10105d:	83 c0 01             	add    $0x1,%eax
  101060:	89 43 04             	mov    %eax,0x4(%ebx)
  release(&ftable.lock);
  101063:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  10106a:	e8 01 32 00 00       	call   104270 <release>
  return f;
}
  10106f:	89 d8                	mov    %ebx,%eax
  101071:	83 c4 14             	add    $0x14,%esp
  101074:	5b                   	pop    %ebx
  101075:	5d                   	pop    %ebp
  101076:	c3                   	ret    
struct file*
filedup(struct file *f)
{
  acquire(&ftable.lock);
  if(f->ref < 1)
    panic("filedup");
  101077:	c7 04 24 d2 6c 10 00 	movl   $0x106cd2,(%esp)
  10107e:	e8 dd f9 ff ff       	call   100a60 <panic>
  101083:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  101089:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101090 <filealloc>:
}

// Allocate a file structure.
struct file*
filealloc(void)
{
  101090:	55                   	push   %ebp
  101091:	89 e5                	mov    %esp,%ebp
  101093:	53                   	push   %ebx
  initlock(&ftable.lock, "ftable");
}

// Allocate a file structure.
struct file*
filealloc(void)
  101094:	bb 2c ae 10 00       	mov    $0x10ae2c,%ebx
{
  101099:	83 ec 14             	sub    $0x14,%esp
  struct file *f;

  acquire(&ftable.lock);
  10109c:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  1010a3:	e8 18 32 00 00       	call   1042c0 <acquire>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    if(f->ref == 0){
  1010a8:	8b 15 18 ae 10 00    	mov    0x10ae18,%edx
  1010ae:	85 d2                	test   %edx,%edx
  1010b0:	75 11                	jne    1010c3 <filealloc+0x33>
  1010b2:	eb 4a                	jmp    1010fe <filealloc+0x6e>
  1010b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
filealloc(void)
{
  struct file *f;

  acquire(&ftable.lock);
  for(f = ftable.file; f < ftable.file + NFILE; f++){
  1010b8:	83 c3 18             	add    $0x18,%ebx
  1010bb:	81 fb 74 b7 10 00    	cmp    $0x10b774,%ebx
  1010c1:	74 25                	je     1010e8 <filealloc+0x58>
    if(f->ref == 0){
  1010c3:	8b 43 04             	mov    0x4(%ebx),%eax
  1010c6:	85 c0                	test   %eax,%eax
  1010c8:	75 ee                	jne    1010b8 <filealloc+0x28>
      f->ref = 1;
  1010ca:	c7 43 04 01 00 00 00 	movl   $0x1,0x4(%ebx)
      release(&ftable.lock);
  1010d1:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  1010d8:	e8 93 31 00 00       	call   104270 <release>
      return f;
    }
  }
  release(&ftable.lock);
  return 0;
}
  1010dd:	89 d8                	mov    %ebx,%eax
  1010df:	83 c4 14             	add    $0x14,%esp
  1010e2:	5b                   	pop    %ebx
  1010e3:	5d                   	pop    %ebp
  1010e4:	c3                   	ret    
  1010e5:	8d 76 00             	lea    0x0(%esi),%esi
      f->ref = 1;
      release(&ftable.lock);
      return f;
    }
  }
  release(&ftable.lock);
  1010e8:	31 db                	xor    %ebx,%ebx
  1010ea:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  1010f1:	e8 7a 31 00 00       	call   104270 <release>
  return 0;
}
  1010f6:	89 d8                	mov    %ebx,%eax
  1010f8:	83 c4 14             	add    $0x14,%esp
  1010fb:	5b                   	pop    %ebx
  1010fc:	5d                   	pop    %ebp
  1010fd:	c3                   	ret    
{
  struct file *f;

  acquire(&ftable.lock);
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    if(f->ref == 0){
  1010fe:	bb 14 ae 10 00       	mov    $0x10ae14,%ebx
  101103:	eb c5                	jmp    1010ca <filealloc+0x3a>
  101105:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  101109:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101110 <fileclose>:
}

// Close file f.  (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
  101110:	55                   	push   %ebp
  101111:	89 e5                	mov    %esp,%ebp
  101113:	83 ec 38             	sub    $0x38,%esp
  101116:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  101119:	8b 5d 08             	mov    0x8(%ebp),%ebx
  10111c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  10111f:	89 7d fc             	mov    %edi,-0x4(%ebp)
  struct file ff;

  acquire(&ftable.lock);
  101122:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  101129:	e8 92 31 00 00       	call   1042c0 <acquire>
  if(f->ref < 1)
  10112e:	8b 43 04             	mov    0x4(%ebx),%eax
  101131:	85 c0                	test   %eax,%eax
  101133:	0f 8e 9c 00 00 00    	jle    1011d5 <fileclose+0xc5>
    panic("fileclose");
  if(--f->ref > 0){
  101139:	83 e8 01             	sub    $0x1,%eax
  10113c:	85 c0                	test   %eax,%eax
  10113e:	89 43 04             	mov    %eax,0x4(%ebx)
  101141:	74 1d                	je     101160 <fileclose+0x50>
    release(&ftable.lock);
  101143:	c7 45 08 e0 ad 10 00 	movl   $0x10ade0,0x8(%ebp)
  
  if(ff.type == FD_PIPE)
    pipeclose(ff.pipe, ff.writable);
  else if(ff.type == FD_INODE)
    iput(ff.ip);
}
  10114a:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  10114d:	8b 75 f8             	mov    -0x8(%ebp),%esi
  101150:	8b 7d fc             	mov    -0x4(%ebp),%edi
  101153:	89 ec                	mov    %ebp,%esp
  101155:	5d                   	pop    %ebp

  acquire(&ftable.lock);
  if(f->ref < 1)
    panic("fileclose");
  if(--f->ref > 0){
    release(&ftable.lock);
  101156:	e9 15 31 00 00       	jmp    104270 <release>
  10115b:	90                   	nop
  10115c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    return;
  }
  ff = *f;
  101160:	8b 43 0c             	mov    0xc(%ebx),%eax
  101163:	8b 7b 10             	mov    0x10(%ebx),%edi
  101166:	89 45 e0             	mov    %eax,-0x20(%ebp)
  101169:	0f b6 43 09          	movzbl 0x9(%ebx),%eax
  10116d:	88 45 e7             	mov    %al,-0x19(%ebp)
  101170:	8b 33                	mov    (%ebx),%esi
  f->ref = 0;
  101172:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
  f->type = FD_NONE;
  101179:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  release(&ftable.lock);
  10117f:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  101186:	e8 e5 30 00 00       	call   104270 <release>
  
  if(ff.type == FD_PIPE)
  10118b:	83 fe 01             	cmp    $0x1,%esi
  10118e:	74 30                	je     1011c0 <fileclose+0xb0>
    pipeclose(ff.pipe, ff.writable);
  else if(ff.type == FD_INODE)
  101190:	83 fe 02             	cmp    $0x2,%esi
  101193:	74 13                	je     1011a8 <fileclose+0x98>
    iput(ff.ip);
}
  101195:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  101198:	8b 75 f8             	mov    -0x8(%ebp),%esi
  10119b:	8b 7d fc             	mov    -0x4(%ebp),%edi
  10119e:	89 ec                	mov    %ebp,%esp
  1011a0:	5d                   	pop    %ebp
  1011a1:	c3                   	ret    
  1011a2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  release(&ftable.lock);
  
  if(ff.type == FD_PIPE)
    pipeclose(ff.pipe, ff.writable);
  else if(ff.type == FD_INODE)
    iput(ff.ip);
  1011a8:	89 7d 08             	mov    %edi,0x8(%ebp)
}
  1011ab:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  1011ae:	8b 75 f8             	mov    -0x8(%ebp),%esi
  1011b1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  1011b4:	89 ec                	mov    %ebp,%esp
  1011b6:	5d                   	pop    %ebp
  release(&ftable.lock);
  
  if(ff.type == FD_PIPE)
    pipeclose(ff.pipe, ff.writable);
  else if(ff.type == FD_INODE)
    iput(ff.ip);
  1011b7:	e9 54 08 00 00       	jmp    101a10 <iput>
  1011bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  f->ref = 0;
  f->type = FD_NONE;
  release(&ftable.lock);
  
  if(ff.type == FD_PIPE)
    pipeclose(ff.pipe, ff.writable);
  1011c0:	0f be 45 e7          	movsbl -0x19(%ebp),%eax
  1011c4:	89 44 24 04          	mov    %eax,0x4(%esp)
  1011c8:	8b 45 e0             	mov    -0x20(%ebp),%eax
  1011cb:	89 04 24             	mov    %eax,(%esp)
  1011ce:	e8 1d 1e 00 00       	call   102ff0 <pipeclose>
  1011d3:	eb c0                	jmp    101195 <fileclose+0x85>
{
  struct file ff;

  acquire(&ftable.lock);
  if(f->ref < 1)
    panic("fileclose");
  1011d5:	c7 04 24 da 6c 10 00 	movl   $0x106cda,(%esp)
  1011dc:	e8 7f f8 ff ff       	call   100a60 <panic>
  1011e1:	eb 0d                	jmp    1011f0 <fileinit>
  1011e3:	90                   	nop
  1011e4:	90                   	nop
  1011e5:	90                   	nop
  1011e6:	90                   	nop
  1011e7:	90                   	nop
  1011e8:	90                   	nop
  1011e9:	90                   	nop
  1011ea:	90                   	nop
  1011eb:	90                   	nop
  1011ec:	90                   	nop
  1011ed:	90                   	nop
  1011ee:	90                   	nop
  1011ef:	90                   	nop

001011f0 <fileinit>:
  struct file file[NFILE];
} ftable;

void
fileinit(void)
{
  1011f0:	55                   	push   %ebp
  1011f1:	89 e5                	mov    %esp,%ebp
  1011f3:	83 ec 18             	sub    $0x18,%esp
  initlock(&ftable.lock, "ftable");
  1011f6:	c7 44 24 04 e4 6c 10 	movl   $0x106ce4,0x4(%esp)
  1011fd:	00 
  1011fe:	c7 04 24 e0 ad 10 00 	movl   $0x10ade0,(%esp)
  101205:	e8 26 2f 00 00       	call   104130 <initlock>
}
  10120a:	c9                   	leave  
  10120b:	c3                   	ret    
  10120c:	90                   	nop
  10120d:	90                   	nop
  10120e:	90                   	nop
  10120f:	90                   	nop

00101210 <stati>:
}

// Copy stat information from inode.
void
stati(struct inode *ip, struct stat *st)
{
  101210:	55                   	push   %ebp
  101211:	89 e5                	mov    %esp,%ebp
  101213:	8b 55 08             	mov    0x8(%ebp),%edx
  101216:	8b 45 0c             	mov    0xc(%ebp),%eax
  st->dev = ip->dev;
  101219:	8b 0a                	mov    (%edx),%ecx
  10121b:	89 48 04             	mov    %ecx,0x4(%eax)
  st->ino = ip->inum;
  10121e:	8b 4a 04             	mov    0x4(%edx),%ecx
  101221:	89 48 08             	mov    %ecx,0x8(%eax)
  st->type = ip->type;
  101224:	0f b7 4a 10          	movzwl 0x10(%edx),%ecx
  101228:	66 89 08             	mov    %cx,(%eax)
  st->nlink = ip->nlink;
  10122b:	0f b7 4a 16          	movzwl 0x16(%edx),%ecx
  10122f:	66 89 48 0c          	mov    %cx,0xc(%eax)
  st->size = ip->size;
  101233:	8b 52 18             	mov    0x18(%edx),%edx
  101236:	89 50 10             	mov    %edx,0x10(%eax)
}
  101239:	5d                   	pop    %ebp
  10123a:	c3                   	ret    
  10123b:	90                   	nop
  10123c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00101240 <idup>:

// Increment reference count for ip.
// Returns ip to enable ip = idup(ip1) idiom.
struct inode*
idup(struct inode *ip)
{
  101240:	55                   	push   %ebp
  101241:	89 e5                	mov    %esp,%ebp
  101243:	53                   	push   %ebx
  101244:	83 ec 14             	sub    $0x14,%esp
  101247:	8b 5d 08             	mov    0x8(%ebp),%ebx
  acquire(&icache.lock);
  10124a:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101251:	e8 6a 30 00 00       	call   1042c0 <acquire>
  ip->ref++;
  101256:	83 43 08 01          	addl   $0x1,0x8(%ebx)
  release(&icache.lock);
  10125a:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101261:	e8 0a 30 00 00       	call   104270 <release>
  return ip;
}
  101266:	89 d8                	mov    %ebx,%eax
  101268:	83 c4 14             	add    $0x14,%esp
  10126b:	5b                   	pop    %ebx
  10126c:	5d                   	pop    %ebp
  10126d:	c3                   	ret    
  10126e:	66 90                	xchg   %ax,%ax

00101270 <iget>:

// Find the inode with number inum on device dev
// and return the in-memory copy.
static struct inode*
iget(uint dev, uint inum)
{
  101270:	55                   	push   %ebp
  101271:	89 e5                	mov    %esp,%ebp
  101273:	57                   	push   %edi
  101274:	89 d7                	mov    %edx,%edi
  101276:	56                   	push   %esi
}

// Find the inode with number inum on device dev
// and return the in-memory copy.
static struct inode*
iget(uint dev, uint inum)
  101277:	31 f6                	xor    %esi,%esi
{
  101279:	53                   	push   %ebx
  10127a:	89 c3                	mov    %eax,%ebx
  10127c:	83 ec 2c             	sub    $0x2c,%esp
  struct inode *ip, *empty;

  acquire(&icache.lock);
  10127f:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101286:	e8 35 30 00 00       	call   1042c0 <acquire>
}

// Find the inode with number inum on device dev
// and return the in-memory copy.
static struct inode*
iget(uint dev, uint inum)
  10128b:	b8 14 b8 10 00       	mov    $0x10b814,%eax
  101290:	eb 14                	jmp    1012a6 <iget+0x36>
  101292:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
      ip->ref++;
      release(&icache.lock);
      return ip;
    }
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
  101298:	85 f6                	test   %esi,%esi
  10129a:	74 3c                	je     1012d8 <iget+0x68>

  acquire(&icache.lock);

  // Try for cached inode.
  empty = 0;
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
  10129c:	83 c0 50             	add    $0x50,%eax
  10129f:	3d b4 c7 10 00       	cmp    $0x10c7b4,%eax
  1012a4:	74 42                	je     1012e8 <iget+0x78>
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
  1012a6:	8b 48 08             	mov    0x8(%eax),%ecx
  1012a9:	85 c9                	test   %ecx,%ecx
  1012ab:	7e eb                	jle    101298 <iget+0x28>
  1012ad:	39 18                	cmp    %ebx,(%eax)
  1012af:	75 e7                	jne    101298 <iget+0x28>
  1012b1:	39 78 04             	cmp    %edi,0x4(%eax)
  1012b4:	75 e2                	jne    101298 <iget+0x28>
      ip->ref++;
  1012b6:	83 c1 01             	add    $0x1,%ecx
  1012b9:	89 48 08             	mov    %ecx,0x8(%eax)
      release(&icache.lock);
  1012bc:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  1012c3:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  1012c6:	e8 a5 2f 00 00       	call   104270 <release>
      return ip;
  1012cb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  ip->ref = 1;
  ip->flags = 0;
  release(&icache.lock);

  return ip;
}
  1012ce:	83 c4 2c             	add    $0x2c,%esp
  1012d1:	5b                   	pop    %ebx
  1012d2:	5e                   	pop    %esi
  1012d3:	5f                   	pop    %edi
  1012d4:	5d                   	pop    %ebp
  1012d5:	c3                   	ret    
  1012d6:	66 90                	xchg   %ax,%ax
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
      ip->ref++;
      release(&icache.lock);
      return ip;
    }
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
  1012d8:	85 c9                	test   %ecx,%ecx
  1012da:	75 c0                	jne    10129c <iget+0x2c>
  1012dc:	89 c6                	mov    %eax,%esi

  acquire(&icache.lock);

  // Try for cached inode.
  empty = 0;
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
  1012de:	83 c0 50             	add    $0x50,%eax
  1012e1:	3d b4 c7 10 00       	cmp    $0x10c7b4,%eax
  1012e6:	75 be                	jne    1012a6 <iget+0x36>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
      empty = ip;
  }

  // Allocate fresh inode.
  if(empty == 0)
  1012e8:	85 f6                	test   %esi,%esi
  1012ea:	74 29                	je     101315 <iget+0xa5>
    panic("iget: no inodes");

  ip = empty;
  ip->dev = dev;
  1012ec:	89 1e                	mov    %ebx,(%esi)
  ip->inum = inum;
  1012ee:	89 7e 04             	mov    %edi,0x4(%esi)
  ip->ref = 1;
  1012f1:	c7 46 08 01 00 00 00 	movl   $0x1,0x8(%esi)
  ip->flags = 0;
  1012f8:	c7 46 0c 00 00 00 00 	movl   $0x0,0xc(%esi)
  release(&icache.lock);
  1012ff:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101306:	e8 65 2f 00 00       	call   104270 <release>

  return ip;
}
  10130b:	83 c4 2c             	add    $0x2c,%esp
  ip = empty;
  ip->dev = dev;
  ip->inum = inum;
  ip->ref = 1;
  ip->flags = 0;
  release(&icache.lock);
  10130e:	89 f0                	mov    %esi,%eax

  return ip;
}
  101310:	5b                   	pop    %ebx
  101311:	5e                   	pop    %esi
  101312:	5f                   	pop    %edi
  101313:	5d                   	pop    %ebp
  101314:	c3                   	ret    
      empty = ip;
  }

  // Allocate fresh inode.
  if(empty == 0)
    panic("iget: no inodes");
  101315:	c7 04 24 eb 6c 10 00 	movl   $0x106ceb,(%esp)
  10131c:	e8 3f f7 ff ff       	call   100a60 <panic>
  101321:	eb 0d                	jmp    101330 <readsb>
  101323:	90                   	nop
  101324:	90                   	nop
  101325:	90                   	nop
  101326:	90                   	nop
  101327:	90                   	nop
  101328:	90                   	nop
  101329:	90                   	nop
  10132a:	90                   	nop
  10132b:	90                   	nop
  10132c:	90                   	nop
  10132d:	90                   	nop
  10132e:	90                   	nop
  10132f:	90                   	nop

00101330 <readsb>:
static void itrunc(struct inode*);

// Read the super block.
static void
readsb(int dev, struct superblock *sb)
{
  101330:	55                   	push   %ebp
  101331:	89 e5                	mov    %esp,%ebp
  101333:	83 ec 18             	sub    $0x18,%esp
  struct buf *bp;
  
  bp = bread(dev, 1);
  101336:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  10133d:	00 
static void itrunc(struct inode*);

// Read the super block.
static void
readsb(int dev, struct superblock *sb)
{
  10133e:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  101341:	89 75 fc             	mov    %esi,-0x4(%ebp)
  101344:	89 d6                	mov    %edx,%esi
  struct buf *bp;
  
  bp = bread(dev, 1);
  101346:	89 04 24             	mov    %eax,(%esp)
  101349:	e8 62 ed ff ff       	call   1000b0 <bread>
  memmove(sb, bp->data, sizeof(*sb));
  10134e:	89 34 24             	mov    %esi,(%esp)
  101351:	c7 44 24 08 0c 00 00 	movl   $0xc,0x8(%esp)
  101358:	00 
static void
readsb(int dev, struct superblock *sb)
{
  struct buf *bp;
  
  bp = bread(dev, 1);
  101359:	89 c3                	mov    %eax,%ebx
  memmove(sb, bp->data, sizeof(*sb));
  10135b:	8d 40 18             	lea    0x18(%eax),%eax
  10135e:	89 44 24 04          	mov    %eax,0x4(%esp)
  101362:	e8 79 30 00 00       	call   1043e0 <memmove>
  brelse(bp);
  101367:	89 1c 24             	mov    %ebx,(%esp)
  10136a:	e8 91 ec ff ff       	call   100000 <brelse>
}
  10136f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  101372:	8b 75 fc             	mov    -0x4(%ebp),%esi
  101375:	89 ec                	mov    %ebp,%esp
  101377:	5d                   	pop    %ebp
  101378:	c3                   	ret    
  101379:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00101380 <balloc>:
// Blocks. 

// Allocate a disk block.
static uint
balloc(uint dev)
{
  101380:	55                   	push   %ebp
  101381:	89 e5                	mov    %esp,%ebp
  101383:	57                   	push   %edi
  101384:	56                   	push   %esi
  101385:	53                   	push   %ebx
  101386:	83 ec 3c             	sub    $0x3c,%esp
  int b, bi, m;
  struct buf *bp;
  struct superblock sb;

  bp = 0;
  readsb(dev, &sb);
  101389:	8d 55 dc             	lea    -0x24(%ebp),%edx
// Blocks. 

// Allocate a disk block.
static uint
balloc(uint dev)
{
  10138c:	89 45 d0             	mov    %eax,-0x30(%ebp)
  int b, bi, m;
  struct buf *bp;
  struct superblock sb;

  bp = 0;
  readsb(dev, &sb);
  10138f:	e8 9c ff ff ff       	call   101330 <readsb>
  for(b = 0; b < sb.size; b += BPB){
  101394:	8b 45 dc             	mov    -0x24(%ebp),%eax
  101397:	85 c0                	test   %eax,%eax
  101399:	0f 84 9c 00 00 00    	je     10143b <balloc+0xbb>
  10139f:	c7 45 d4 00 00 00 00 	movl   $0x0,-0x2c(%ebp)
    bp = bread(dev, BBLOCK(b, sb.ninodes));
  1013a6:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1013a9:	31 db                	xor    %ebx,%ebx
  1013ab:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  1013ae:	c1 e8 03             	shr    $0x3,%eax
  1013b1:	c1 fa 0c             	sar    $0xc,%edx
  1013b4:	8d 44 10 03          	lea    0x3(%eax,%edx,1),%eax
  1013b8:	89 44 24 04          	mov    %eax,0x4(%esp)
  1013bc:	8b 45 d0             	mov    -0x30(%ebp),%eax
  1013bf:	89 04 24             	mov    %eax,(%esp)
  1013c2:	e8 e9 ec ff ff       	call   1000b0 <bread>
  1013c7:	89 c6                	mov    %eax,%esi
  1013c9:	eb 10                	jmp    1013db <balloc+0x5b>
  1013cb:	90                   	nop
  1013cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    for(bi = 0; bi < BPB; bi++){
  1013d0:	83 c3 01             	add    $0x1,%ebx
  1013d3:	81 fb 00 10 00 00    	cmp    $0x1000,%ebx
  1013d9:	74 45                	je     101420 <balloc+0xa0>
      m = 1 << (bi % 8);
  1013db:	89 d9                	mov    %ebx,%ecx
  1013dd:	ba 01 00 00 00       	mov    $0x1,%edx
  1013e2:	83 e1 07             	and    $0x7,%ecx
      if((bp->data[bi/8] & m) == 0){  // Is block free?
  1013e5:	89 d8                	mov    %ebx,%eax
  bp = 0;
  readsb(dev, &sb);
  for(b = 0; b < sb.size; b += BPB){
    bp = bread(dev, BBLOCK(b, sb.ninodes));
    for(bi = 0; bi < BPB; bi++){
      m = 1 << (bi % 8);
  1013e7:	d3 e2                	shl    %cl,%edx
      if((bp->data[bi/8] & m) == 0){  // Is block free?
  1013e9:	c1 f8 03             	sar    $0x3,%eax
  bp = 0;
  readsb(dev, &sb);
  for(b = 0; b < sb.size; b += BPB){
    bp = bread(dev, BBLOCK(b, sb.ninodes));
    for(bi = 0; bi < BPB; bi++){
      m = 1 << (bi % 8);
  1013ec:	89 d1                	mov    %edx,%ecx
      if((bp->data[bi/8] & m) == 0){  // Is block free?
  1013ee:	0f b6 54 06 18       	movzbl 0x18(%esi,%eax,1),%edx
  1013f3:	0f b6 fa             	movzbl %dl,%edi
  1013f6:	85 cf                	test   %ecx,%edi
  1013f8:	75 d6                	jne    1013d0 <balloc+0x50>
        bp->data[bi/8] |= m;  // Mark block in use on disk.
  1013fa:	09 d1                	or     %edx,%ecx
  1013fc:	88 4c 06 18          	mov    %cl,0x18(%esi,%eax,1)
        bwrite(bp);
  101400:	89 34 24             	mov    %esi,(%esp)
  101403:	e8 78 ec ff ff       	call   100080 <bwrite>
        brelse(bp);
  101408:	89 34 24             	mov    %esi,(%esp)
  10140b:	e8 f0 eb ff ff       	call   100000 <brelse>
  101410:	8b 55 d4             	mov    -0x2c(%ebp),%edx
      }
    }
    brelse(bp);
  }
  panic("balloc: out of blocks");
}
  101413:	83 c4 3c             	add    $0x3c,%esp
    for(bi = 0; bi < BPB; bi++){
      m = 1 << (bi % 8);
      if((bp->data[bi/8] & m) == 0){  // Is block free?
        bp->data[bi/8] |= m;  // Mark block in use on disk.
        bwrite(bp);
        brelse(bp);
  101416:	8d 04 13             	lea    (%ebx,%edx,1),%eax
      }
    }
    brelse(bp);
  }
  panic("balloc: out of blocks");
}
  101419:	5b                   	pop    %ebx
  10141a:	5e                   	pop    %esi
  10141b:	5f                   	pop    %edi
  10141c:	5d                   	pop    %ebp
  10141d:	c3                   	ret    
  10141e:	66 90                	xchg   %ax,%ax
        bwrite(bp);
        brelse(bp);
        return b + bi;
      }
    }
    brelse(bp);
  101420:	89 34 24             	mov    %esi,(%esp)
  101423:	e8 d8 eb ff ff       	call   100000 <brelse>
  struct buf *bp;
  struct superblock sb;

  bp = 0;
  readsb(dev, &sb);
  for(b = 0; b < sb.size; b += BPB){
  101428:	81 45 d4 00 10 00 00 	addl   $0x1000,-0x2c(%ebp)
  10142f:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  101432:	39 45 dc             	cmp    %eax,-0x24(%ebp)
  101435:	0f 87 6b ff ff ff    	ja     1013a6 <balloc+0x26>
        return b + bi;
      }
    }
    brelse(bp);
  }
  panic("balloc: out of blocks");
  10143b:	c7 04 24 fb 6c 10 00 	movl   $0x106cfb,(%esp)
  101442:	e8 19 f6 ff ff       	call   100a60 <panic>
  101447:	89 f6                	mov    %esi,%esi
  101449:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101450 <bmap>:

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
  101450:	55                   	push   %ebp
  101451:	89 e5                	mov    %esp,%ebp
  101453:	83 ec 38             	sub    $0x38,%esp
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
  101456:	83 fa 0b             	cmp    $0xb,%edx

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
  101459:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  10145c:	89 c3                	mov    %eax,%ebx
  10145e:	89 75 f8             	mov    %esi,-0x8(%ebp)
  101461:	89 7d fc             	mov    %edi,-0x4(%ebp)
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
  101464:	77 1a                	ja     101480 <bmap+0x30>
    if((addr = ip->addrs[bn]) == 0)
  101466:	8d 7a 04             	lea    0x4(%edx),%edi
  101469:	8b 44 b8 0c          	mov    0xc(%eax,%edi,4),%eax
  10146d:	85 c0                	test   %eax,%eax
  10146f:	74 5f                	je     1014d0 <bmap+0x80>
    brelse(bp);
    return addr;
  }

  panic("bmap: out of range");
}
  101471:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  101474:	8b 75 f8             	mov    -0x8(%ebp),%esi
  101477:	8b 7d fc             	mov    -0x4(%ebp),%edi
  10147a:	89 ec                	mov    %ebp,%esp
  10147c:	5d                   	pop    %ebp
  10147d:	c3                   	ret    
  10147e:	66 90                	xchg   %ax,%ax
  if(bn < NDIRECT){
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
    return addr;
  }
  bn -= NDIRECT;
  101480:	8d 7a f4             	lea    -0xc(%edx),%edi

  if(bn < NINDIRECT){
  101483:	83 ff 7f             	cmp    $0x7f,%edi
  101486:	77 64                	ja     1014ec <bmap+0x9c>
    // Load indirect block, allocating if necessary.
    if((addr = ip->addrs[NDIRECT]) == 0)
  101488:	8b 40 4c             	mov    0x4c(%eax),%eax
  10148b:	85 c0                	test   %eax,%eax
  10148d:	74 51                	je     1014e0 <bmap+0x90>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    bp = bread(ip->dev, addr);
  10148f:	89 44 24 04          	mov    %eax,0x4(%esp)
  101493:	8b 03                	mov    (%ebx),%eax
  101495:	89 04 24             	mov    %eax,(%esp)
  101498:	e8 13 ec ff ff       	call   1000b0 <bread>
    a = (uint*)bp->data;
    if((addr = a[bn]) == 0){
  10149d:	8d 7c b8 18          	lea    0x18(%eax,%edi,4),%edi

  if(bn < NINDIRECT){
    // Load indirect block, allocating if necessary.
    if((addr = ip->addrs[NDIRECT]) == 0)
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    bp = bread(ip->dev, addr);
  1014a1:	89 c6                	mov    %eax,%esi
    a = (uint*)bp->data;
    if((addr = a[bn]) == 0){
  1014a3:	8b 07                	mov    (%edi),%eax
  1014a5:	85 c0                	test   %eax,%eax
  1014a7:	75 17                	jne    1014c0 <bmap+0x70>
      a[bn] = addr = balloc(ip->dev);
  1014a9:	8b 03                	mov    (%ebx),%eax
  1014ab:	e8 d0 fe ff ff       	call   101380 <balloc>
  1014b0:	89 07                	mov    %eax,(%edi)
      bwrite(bp);
  1014b2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  1014b5:	89 34 24             	mov    %esi,(%esp)
  1014b8:	e8 c3 eb ff ff       	call   100080 <bwrite>
  1014bd:	8b 45 e4             	mov    -0x1c(%ebp),%eax
    }
    brelse(bp);
  1014c0:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  1014c3:	89 34 24             	mov    %esi,(%esp)
  1014c6:	e8 35 eb ff ff       	call   100000 <brelse>
    return addr;
  1014cb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1014ce:	eb a1                	jmp    101471 <bmap+0x21>
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
  1014d0:	8b 03                	mov    (%ebx),%eax
  1014d2:	e8 a9 fe ff ff       	call   101380 <balloc>
  1014d7:	89 44 bb 0c          	mov    %eax,0xc(%ebx,%edi,4)
  1014db:	eb 94                	jmp    101471 <bmap+0x21>
  1014dd:	8d 76 00             	lea    0x0(%esi),%esi
  bn -= NDIRECT;

  if(bn < NINDIRECT){
    // Load indirect block, allocating if necessary.
    if((addr = ip->addrs[NDIRECT]) == 0)
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
  1014e0:	8b 03                	mov    (%ebx),%eax
  1014e2:	e8 99 fe ff ff       	call   101380 <balloc>
  1014e7:	89 43 4c             	mov    %eax,0x4c(%ebx)
  1014ea:	eb a3                	jmp    10148f <bmap+0x3f>
    }
    brelse(bp);
    return addr;
  }

  panic("bmap: out of range");
  1014ec:	c7 04 24 11 6d 10 00 	movl   $0x106d11,(%esp)
  1014f3:	e8 68 f5 ff ff       	call   100a60 <panic>
  1014f8:	90                   	nop
  1014f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00101500 <readi>:
}

// Read data from inode.
int
readi(struct inode *ip, char *dst, uint off, uint n)
{
  101500:	55                   	push   %ebp
  101501:	89 e5                	mov    %esp,%ebp
  101503:	83 ec 38             	sub    $0x38,%esp
  101506:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  101509:	8b 5d 08             	mov    0x8(%ebp),%ebx
  10150c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  10150f:	8b 4d 14             	mov    0x14(%ebp),%ecx
  101512:	89 7d fc             	mov    %edi,-0x4(%ebp)
  101515:	8b 75 10             	mov    0x10(%ebp),%esi
  101518:	8b 7d 0c             	mov    0xc(%ebp),%edi
  uint tot, m;
  struct buf *bp;

  if(ip->type == T_DEV){
  10151b:	66 83 7b 10 03       	cmpw   $0x3,0x10(%ebx)
  101520:	74 1e                	je     101540 <readi+0x40>
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
      return -1;
    return devsw[ip->major].read(ip, dst, n);
  }

  if(off > ip->size || off + n < off)
  101522:	8b 43 18             	mov    0x18(%ebx),%eax
  101525:	39 f0                	cmp    %esi,%eax
  101527:	73 3f                	jae    101568 <readi+0x68>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(dst, bp->data + off%BSIZE, m);
    brelse(bp);
  }
  return n;
  101529:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  10152e:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  101531:	8b 75 f8             	mov    -0x8(%ebp),%esi
  101534:	8b 7d fc             	mov    -0x4(%ebp),%edi
  101537:	89 ec                	mov    %ebp,%esp
  101539:	5d                   	pop    %ebp
  10153a:	c3                   	ret    
  10153b:	90                   	nop
  10153c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
  uint tot, m;
  struct buf *bp;

  if(ip->type == T_DEV){
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
  101540:	0f b7 43 12          	movzwl 0x12(%ebx),%eax
  101544:	66 83 f8 09          	cmp    $0x9,%ax
  101548:	77 df                	ja     101529 <readi+0x29>
  10154a:	98                   	cwtl   
  10154b:	8b 04 c5 80 b7 10 00 	mov    0x10b780(,%eax,8),%eax
  101552:	85 c0                	test   %eax,%eax
  101554:	74 d3                	je     101529 <readi+0x29>
      return -1;
    return devsw[ip->major].read(ip, dst, n);
  101556:	89 4d 10             	mov    %ecx,0x10(%ebp)
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(dst, bp->data + off%BSIZE, m);
    brelse(bp);
  }
  return n;
}
  101559:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  10155c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  10155f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  101562:	89 ec                	mov    %ebp,%esp
  101564:	5d                   	pop    %ebp
  struct buf *bp;

  if(ip->type == T_DEV){
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
      return -1;
    return devsw[ip->major].read(ip, dst, n);
  101565:	ff e0                	jmp    *%eax
  101567:	90                   	nop
  }

  if(off > ip->size || off + n < off)
  101568:	89 ca                	mov    %ecx,%edx
  10156a:	01 f2                	add    %esi,%edx
  10156c:	72 bb                	jb     101529 <readi+0x29>
    return -1;
  if(off + n > ip->size)
  10156e:	39 d0                	cmp    %edx,%eax
  101570:	73 04                	jae    101576 <readi+0x76>
    n = ip->size - off;
  101572:	89 c1                	mov    %eax,%ecx
  101574:	29 f1                	sub    %esi,%ecx

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
  101576:	85 c9                	test   %ecx,%ecx
  101578:	74 7c                	je     1015f6 <readi+0xf6>
  10157a:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
  101581:	89 7d e0             	mov    %edi,-0x20(%ebp)
  101584:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  101587:	90                   	nop
    return -1;
  if(off + n > ip->size)
    n = ip->size - off;

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
  101588:	89 f2                	mov    %esi,%edx
  10158a:	89 d8                	mov    %ebx,%eax
  10158c:	c1 ea 09             	shr    $0x9,%edx
    m = min(n - tot, BSIZE - off%BSIZE);
  10158f:	bf 00 02 00 00       	mov    $0x200,%edi
    return -1;
  if(off + n > ip->size)
    n = ip->size - off;

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
  101594:	e8 b7 fe ff ff       	call   101450 <bmap>
  101599:	89 44 24 04          	mov    %eax,0x4(%esp)
  10159d:	8b 03                	mov    (%ebx),%eax
  10159f:	89 04 24             	mov    %eax,(%esp)
  1015a2:	e8 09 eb ff ff       	call   1000b0 <bread>
    m = min(n - tot, BSIZE - off%BSIZE);
  1015a7:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  1015aa:	2b 4d e4             	sub    -0x1c(%ebp),%ecx
    return -1;
  if(off + n > ip->size)
    n = ip->size - off;

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
  1015ad:	89 c2                	mov    %eax,%edx
    m = min(n - tot, BSIZE - off%BSIZE);
  1015af:	89 f0                	mov    %esi,%eax
  1015b1:	25 ff 01 00 00       	and    $0x1ff,%eax
  1015b6:	29 c7                	sub    %eax,%edi
  1015b8:	39 cf                	cmp    %ecx,%edi
  1015ba:	76 02                	jbe    1015be <readi+0xbe>
  1015bc:	89 cf                	mov    %ecx,%edi
    memmove(dst, bp->data + off%BSIZE, m);
  1015be:	8d 44 02 18          	lea    0x18(%edx,%eax,1),%eax
  if(off > ip->size || off + n < off)
    return -1;
  if(off + n > ip->size)
    n = ip->size - off;

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
  1015c2:	01 fe                	add    %edi,%esi
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(dst, bp->data + off%BSIZE, m);
  1015c4:	89 7c 24 08          	mov    %edi,0x8(%esp)
  1015c8:	89 44 24 04          	mov    %eax,0x4(%esp)
  1015cc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  1015cf:	89 04 24             	mov    %eax,(%esp)
  1015d2:	89 55 d8             	mov    %edx,-0x28(%ebp)
  1015d5:	e8 06 2e 00 00       	call   1043e0 <memmove>
    brelse(bp);
  1015da:	8b 55 d8             	mov    -0x28(%ebp),%edx
  1015dd:	89 14 24             	mov    %edx,(%esp)
  1015e0:	e8 1b ea ff ff       	call   100000 <brelse>
  if(off > ip->size || off + n < off)
    return -1;
  if(off + n > ip->size)
    n = ip->size - off;

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
  1015e5:	01 7d e4             	add    %edi,-0x1c(%ebp)
  1015e8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1015eb:	01 7d e0             	add    %edi,-0x20(%ebp)
  1015ee:	39 45 dc             	cmp    %eax,-0x24(%ebp)
  1015f1:	77 95                	ja     101588 <readi+0x88>
  1015f3:	8b 4d dc             	mov    -0x24(%ebp),%ecx
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(dst, bp->data + off%BSIZE, m);
    brelse(bp);
  }
  return n;
  1015f6:	89 c8                	mov    %ecx,%eax
  1015f8:	e9 31 ff ff ff       	jmp    10152e <readi+0x2e>
  1015fd:	8d 76 00             	lea    0x0(%esi),%esi

00101600 <iupdate>:
}

// Copy inode, which has changed, from memory to disk.
void
iupdate(struct inode *ip)
{
  101600:	55                   	push   %ebp
  101601:	89 e5                	mov    %esp,%ebp
  101603:	56                   	push   %esi
  101604:	53                   	push   %ebx
  101605:	83 ec 10             	sub    $0x10,%esp
  101608:	8b 5d 08             	mov    0x8(%ebp),%ebx
  struct buf *bp;
  struct dinode *dip;

  bp = bread(ip->dev, IBLOCK(ip->inum));
  10160b:	8b 43 04             	mov    0x4(%ebx),%eax
  10160e:	c1 e8 03             	shr    $0x3,%eax
  101611:	83 c0 02             	add    $0x2,%eax
  101614:	89 44 24 04          	mov    %eax,0x4(%esp)
  101618:	8b 03                	mov    (%ebx),%eax
  10161a:	89 04 24             	mov    %eax,(%esp)
  10161d:	e8 8e ea ff ff       	call   1000b0 <bread>
  dip = (struct dinode*)bp->data + ip->inum%IPB;
  dip->type = ip->type;
  101622:	0f b7 53 10          	movzwl 0x10(%ebx),%edx
iupdate(struct inode *ip)
{
  struct buf *bp;
  struct dinode *dip;

  bp = bread(ip->dev, IBLOCK(ip->inum));
  101626:	89 c6                	mov    %eax,%esi
  dip = (struct dinode*)bp->data + ip->inum%IPB;
  101628:	8b 43 04             	mov    0x4(%ebx),%eax
  10162b:	83 e0 07             	and    $0x7,%eax
  10162e:	c1 e0 06             	shl    $0x6,%eax
  101631:	8d 44 06 18          	lea    0x18(%esi,%eax,1),%eax
  dip->type = ip->type;
  101635:	66 89 10             	mov    %dx,(%eax)
  dip->major = ip->major;
  101638:	0f b7 53 12          	movzwl 0x12(%ebx),%edx
  10163c:	66 89 50 02          	mov    %dx,0x2(%eax)
  dip->minor = ip->minor;
  101640:	0f b7 53 14          	movzwl 0x14(%ebx),%edx
  101644:	66 89 50 04          	mov    %dx,0x4(%eax)
  dip->nlink = ip->nlink;
  101648:	0f b7 53 16          	movzwl 0x16(%ebx),%edx
  10164c:	66 89 50 06          	mov    %dx,0x6(%eax)
  dip->size = ip->size;
  101650:	8b 53 18             	mov    0x18(%ebx),%edx
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
  101653:	83 c3 1c             	add    $0x1c,%ebx
  dip = (struct dinode*)bp->data + ip->inum%IPB;
  dip->type = ip->type;
  dip->major = ip->major;
  dip->minor = ip->minor;
  dip->nlink = ip->nlink;
  dip->size = ip->size;
  101656:	89 50 08             	mov    %edx,0x8(%eax)
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
  101659:	83 c0 0c             	add    $0xc,%eax
  10165c:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  101660:	c7 44 24 08 34 00 00 	movl   $0x34,0x8(%esp)
  101667:	00 
  101668:	89 04 24             	mov    %eax,(%esp)
  10166b:	e8 70 2d 00 00       	call   1043e0 <memmove>
  bwrite(bp);
  101670:	89 34 24             	mov    %esi,(%esp)
  101673:	e8 08 ea ff ff       	call   100080 <bwrite>
  brelse(bp);
  101678:	89 75 08             	mov    %esi,0x8(%ebp)
}
  10167b:	83 c4 10             	add    $0x10,%esp
  10167e:	5b                   	pop    %ebx
  10167f:	5e                   	pop    %esi
  101680:	5d                   	pop    %ebp
  dip->minor = ip->minor;
  dip->nlink = ip->nlink;
  dip->size = ip->size;
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
  bwrite(bp);
  brelse(bp);
  101681:	e9 7a e9 ff ff       	jmp    100000 <brelse>
  101686:	8d 76 00             	lea    0x0(%esi),%esi
  101689:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101690 <writei>:
}

// Write data to inode.
int
writei(struct inode *ip, char *src, uint off, uint n)
{
  101690:	55                   	push   %ebp
  101691:	89 e5                	mov    %esp,%ebp
  101693:	83 ec 38             	sub    $0x38,%esp
  101696:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  101699:	8b 5d 08             	mov    0x8(%ebp),%ebx
  10169c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  10169f:	8b 4d 14             	mov    0x14(%ebp),%ecx
  1016a2:	89 7d fc             	mov    %edi,-0x4(%ebp)
  1016a5:	8b 75 10             	mov    0x10(%ebp),%esi
  1016a8:	8b 7d 0c             	mov    0xc(%ebp),%edi
  uint tot, m;
  struct buf *bp;

  if(ip->type == T_DEV){
  1016ab:	66 83 7b 10 03       	cmpw   $0x3,0x10(%ebx)
  1016b0:	74 1e                	je     1016d0 <writei+0x40>
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
      return -1;
    return devsw[ip->major].write(ip, src, n);
  }

  if(off > ip->size || off + n < off)
  1016b2:	39 73 18             	cmp    %esi,0x18(%ebx)
  1016b5:	73 41                	jae    1016f8 <writei+0x68>

  if(n > 0 && off > ip->size){
    ip->size = off;
    iupdate(ip);
  }
  return n;
  1016b7:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  1016bc:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  1016bf:	8b 75 f8             	mov    -0x8(%ebp),%esi
  1016c2:	8b 7d fc             	mov    -0x4(%ebp),%edi
  1016c5:	89 ec                	mov    %ebp,%esp
  1016c7:	5d                   	pop    %ebp
  1016c8:	c3                   	ret    
  1016c9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
{
  uint tot, m;
  struct buf *bp;

  if(ip->type == T_DEV){
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
  1016d0:	0f b7 43 12          	movzwl 0x12(%ebx),%eax
  1016d4:	66 83 f8 09          	cmp    $0x9,%ax
  1016d8:	77 dd                	ja     1016b7 <writei+0x27>
  1016da:	98                   	cwtl   
  1016db:	8b 04 c5 84 b7 10 00 	mov    0x10b784(,%eax,8),%eax
  1016e2:	85 c0                	test   %eax,%eax
  1016e4:	74 d1                	je     1016b7 <writei+0x27>
      return -1;
    return devsw[ip->major].write(ip, src, n);
  1016e6:	89 4d 10             	mov    %ecx,0x10(%ebp)
  if(n > 0 && off > ip->size){
    ip->size = off;
    iupdate(ip);
  }
  return n;
}
  1016e9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  1016ec:	8b 75 f8             	mov    -0x8(%ebp),%esi
  1016ef:	8b 7d fc             	mov    -0x4(%ebp),%edi
  1016f2:	89 ec                	mov    %ebp,%esp
  1016f4:	5d                   	pop    %ebp
  struct buf *bp;

  if(ip->type == T_DEV){
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
      return -1;
    return devsw[ip->major].write(ip, src, n);
  1016f5:	ff e0                	jmp    *%eax
  1016f7:	90                   	nop
  }

  if(off > ip->size || off + n < off)
  1016f8:	89 c8                	mov    %ecx,%eax
  1016fa:	01 f0                	add    %esi,%eax
  1016fc:	72 b9                	jb     1016b7 <writei+0x27>
    return -1;
  if(off + n > MAXFILE*BSIZE)
  1016fe:	3d 00 18 01 00       	cmp    $0x11800,%eax
  101703:	76 07                	jbe    10170c <writei+0x7c>
    n = MAXFILE*BSIZE - off;
  101705:	b9 00 18 01 00       	mov    $0x11800,%ecx
  10170a:	29 f1                	sub    %esi,%ecx

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
  10170c:	85 c9                	test   %ecx,%ecx
  10170e:	0f 84 92 00 00 00    	je     1017a6 <writei+0x116>
  101714:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
  10171b:	89 7d e0             	mov    %edi,-0x20(%ebp)
  10171e:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  101721:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
  101728:	89 f2                	mov    %esi,%edx
  10172a:	89 d8                	mov    %ebx,%eax
  10172c:	c1 ea 09             	shr    $0x9,%edx
    m = min(n - tot, BSIZE - off%BSIZE);
  10172f:	bf 00 02 00 00       	mov    $0x200,%edi
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
  101734:	e8 17 fd ff ff       	call   101450 <bmap>
  101739:	89 44 24 04          	mov    %eax,0x4(%esp)
  10173d:	8b 03                	mov    (%ebx),%eax
  10173f:	89 04 24             	mov    %eax,(%esp)
  101742:	e8 69 e9 ff ff       	call   1000b0 <bread>
    m = min(n - tot, BSIZE - off%BSIZE);
  101747:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  10174a:	2b 4d e4             	sub    -0x1c(%ebp),%ecx
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
  10174d:	89 c2                	mov    %eax,%edx
    m = min(n - tot, BSIZE - off%BSIZE);
  10174f:	89 f0                	mov    %esi,%eax
  101751:	25 ff 01 00 00       	and    $0x1ff,%eax
  101756:	29 c7                	sub    %eax,%edi
  101758:	39 cf                	cmp    %ecx,%edi
  10175a:	76 02                	jbe    10175e <writei+0xce>
  10175c:	89 cf                	mov    %ecx,%edi
    memmove(bp->data + off%BSIZE, src, m);
  10175e:	89 7c 24 08          	mov    %edi,0x8(%esp)
  101762:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  101765:	8d 44 02 18          	lea    0x18(%edx,%eax,1),%eax
  101769:	89 04 24             	mov    %eax,(%esp)
  if(off > ip->size || off + n < off)
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
  10176c:	01 fe                	add    %edi,%esi
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(bp->data + off%BSIZE, src, m);
  10176e:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  101772:	89 55 d8             	mov    %edx,-0x28(%ebp)
  101775:	e8 66 2c 00 00       	call   1043e0 <memmove>
    bwrite(bp);
  10177a:	8b 55 d8             	mov    -0x28(%ebp),%edx
  10177d:	89 14 24             	mov    %edx,(%esp)
  101780:	e8 fb e8 ff ff       	call   100080 <bwrite>
    brelse(bp);
  101785:	8b 55 d8             	mov    -0x28(%ebp),%edx
  101788:	89 14 24             	mov    %edx,(%esp)
  10178b:	e8 70 e8 ff ff       	call   100000 <brelse>
  if(off > ip->size || off + n < off)
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
  101790:	01 7d e4             	add    %edi,-0x1c(%ebp)
  101793:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101796:	01 7d e0             	add    %edi,-0x20(%ebp)
  101799:	39 45 dc             	cmp    %eax,-0x24(%ebp)
  10179c:	77 8a                	ja     101728 <writei+0x98>
    memmove(bp->data + off%BSIZE, src, m);
    bwrite(bp);
    brelse(bp);
  }

  if(n > 0 && off > ip->size){
  10179e:	3b 73 18             	cmp    0x18(%ebx),%esi
  1017a1:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  1017a4:	77 07                	ja     1017ad <writei+0x11d>
    ip->size = off;
    iupdate(ip);
  }
  return n;
  1017a6:	89 c8                	mov    %ecx,%eax
  1017a8:	e9 0f ff ff ff       	jmp    1016bc <writei+0x2c>
    bwrite(bp);
    brelse(bp);
  }

  if(n > 0 && off > ip->size){
    ip->size = off;
  1017ad:	89 73 18             	mov    %esi,0x18(%ebx)
    iupdate(ip);
  1017b0:	89 1c 24             	mov    %ebx,(%esp)
  1017b3:	89 4d d8             	mov    %ecx,-0x28(%ebp)
  1017b6:	e8 45 fe ff ff       	call   101600 <iupdate>
  1017bb:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  }
  return n;
  1017be:	89 c8                	mov    %ecx,%eax
  1017c0:	e9 f7 fe ff ff       	jmp    1016bc <writei+0x2c>
  1017c5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1017c9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001017d0 <namecmp>:

// Directories

int
namecmp(const char *s, const char *t)
{
  1017d0:	55                   	push   %ebp
  1017d1:	89 e5                	mov    %esp,%ebp
  1017d3:	83 ec 18             	sub    $0x18,%esp
  return strncmp(s, t, DIRSIZ);
  1017d6:	8b 45 0c             	mov    0xc(%ebp),%eax
  1017d9:	c7 44 24 08 0e 00 00 	movl   $0xe,0x8(%esp)
  1017e0:	00 
  1017e1:	89 44 24 04          	mov    %eax,0x4(%esp)
  1017e5:	8b 45 08             	mov    0x8(%ebp),%eax
  1017e8:	89 04 24             	mov    %eax,(%esp)
  1017eb:	e8 60 2c 00 00       	call   104450 <strncmp>
}
  1017f0:	c9                   	leave  
  1017f1:	c3                   	ret    
  1017f2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  1017f9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101800 <dirlookup>:
// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
// Caller must have already locked dp.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
  101800:	55                   	push   %ebp
  101801:	89 e5                	mov    %esp,%ebp
  101803:	57                   	push   %edi
  101804:	56                   	push   %esi
  101805:	53                   	push   %ebx
  101806:	83 ec 3c             	sub    $0x3c,%esp
  101809:	8b 45 08             	mov    0x8(%ebp),%eax
  10180c:	8b 55 10             	mov    0x10(%ebp),%edx
  10180f:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  101812:	89 45 dc             	mov    %eax,-0x24(%ebp)
  101815:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  uint off, inum;
  struct buf *bp;
  struct dirent *de;

  if(dp->type != T_DIR)
  101818:	66 83 78 10 01       	cmpw   $0x1,0x10(%eax)
  10181d:	0f 85 d0 00 00 00    	jne    1018f3 <dirlookup+0xf3>
    panic("dirlookup not DIR");
  101823:	c7 45 e0 00 00 00 00 	movl   $0x0,-0x20(%ebp)

  for(off = 0; off < dp->size; off += BSIZE){
  10182a:	8b 48 18             	mov    0x18(%eax),%ecx
  10182d:	85 c9                	test   %ecx,%ecx
  10182f:	0f 84 b4 00 00 00    	je     1018e9 <dirlookup+0xe9>
    bp = bread(dp->dev, bmap(dp, off / BSIZE));
  101835:	8b 55 e0             	mov    -0x20(%ebp),%edx
  101838:	8b 45 dc             	mov    -0x24(%ebp),%eax
  10183b:	c1 ea 09             	shr    $0x9,%edx
  10183e:	e8 0d fc ff ff       	call   101450 <bmap>
  101843:	89 44 24 04          	mov    %eax,0x4(%esp)
  101847:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  10184a:	8b 01                	mov    (%ecx),%eax
  10184c:	89 04 24             	mov    %eax,(%esp)
  10184f:	e8 5c e8 ff ff       	call   1000b0 <bread>
  101854:	89 45 e4             	mov    %eax,-0x1c(%ebp)

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
// Caller must have already locked dp.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
  101857:	8b 7d e4             	mov    -0x1c(%ebp),%edi
  if(dp->type != T_DIR)
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += BSIZE){
    bp = bread(dp->dev, bmap(dp, off / BSIZE));
    for(de = (struct dirent*)bp->data;
  10185a:	83 c0 18             	add    $0x18,%eax
  10185d:	89 45 d8             	mov    %eax,-0x28(%ebp)
  101860:	89 c6                	mov    %eax,%esi

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
// Caller must have already locked dp.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
  101862:	81 c7 18 02 00 00    	add    $0x218,%edi
  101868:	eb 0d                	jmp    101877 <dirlookup+0x77>
  10186a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  for(off = 0; off < dp->size; off += BSIZE){
    bp = bread(dp->dev, bmap(dp, off / BSIZE));
    for(de = (struct dirent*)bp->data;
        de < (struct dirent*)(bp->data + BSIZE);
        de++){
  101870:	83 c6 10             	add    $0x10,%esi
  if(dp->type != T_DIR)
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += BSIZE){
    bp = bread(dp->dev, bmap(dp, off / BSIZE));
    for(de = (struct dirent*)bp->data;
  101873:	39 fe                	cmp    %edi,%esi
  101875:	74 51                	je     1018c8 <dirlookup+0xc8>
        de < (struct dirent*)(bp->data + BSIZE);
        de++){
      if(de->inum == 0)
  101877:	66 83 3e 00          	cmpw   $0x0,(%esi)
  10187b:	74 f3                	je     101870 <dirlookup+0x70>
        continue;
      if(namecmp(name, de->name) == 0){
  10187d:	8d 46 02             	lea    0x2(%esi),%eax
  101880:	89 44 24 04          	mov    %eax,0x4(%esp)
  101884:	89 1c 24             	mov    %ebx,(%esp)
  101887:	e8 44 ff ff ff       	call   1017d0 <namecmp>
  10188c:	85 c0                	test   %eax,%eax
  10188e:	75 e0                	jne    101870 <dirlookup+0x70>
        // entry matches path element
        if(poff)
  101890:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  101893:	85 d2                	test   %edx,%edx
  101895:	74 0e                	je     1018a5 <dirlookup+0xa5>
          *poff = off + (uchar*)de - bp->data;
  101897:	8b 55 e0             	mov    -0x20(%ebp),%edx
  10189a:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
  10189d:	8d 04 16             	lea    (%esi,%edx,1),%eax
  1018a0:	2b 45 d8             	sub    -0x28(%ebp),%eax
  1018a3:	89 01                	mov    %eax,(%ecx)
        inum = de->inum;
        brelse(bp);
  1018a5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
        continue;
      if(namecmp(name, de->name) == 0){
        // entry matches path element
        if(poff)
          *poff = off + (uchar*)de - bp->data;
        inum = de->inum;
  1018a8:	0f b7 1e             	movzwl (%esi),%ebx
        brelse(bp);
  1018ab:	89 04 24             	mov    %eax,(%esp)
  1018ae:	e8 4d e7 ff ff       	call   100000 <brelse>
        return iget(dp->dev, inum);
  1018b3:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  1018b6:	89 da                	mov    %ebx,%edx
  1018b8:	8b 01                	mov    (%ecx),%eax
      }
    }
    brelse(bp);
  }
  return 0;
}
  1018ba:	83 c4 3c             	add    $0x3c,%esp
  1018bd:	5b                   	pop    %ebx
  1018be:	5e                   	pop    %esi
  1018bf:	5f                   	pop    %edi
  1018c0:	5d                   	pop    %ebp
        // entry matches path element
        if(poff)
          *poff = off + (uchar*)de - bp->data;
        inum = de->inum;
        brelse(bp);
        return iget(dp->dev, inum);
  1018c1:	e9 aa f9 ff ff       	jmp    101270 <iget>
  1018c6:	66 90                	xchg   %ax,%ax
      }
    }
    brelse(bp);
  1018c8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1018cb:	89 04 24             	mov    %eax,(%esp)
  1018ce:	e8 2d e7 ff ff       	call   100000 <brelse>
  struct dirent *de;

  if(dp->type != T_DIR)
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += BSIZE){
  1018d3:	8b 55 dc             	mov    -0x24(%ebp),%edx
  1018d6:	81 45 e0 00 02 00 00 	addl   $0x200,-0x20(%ebp)
  1018dd:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  1018e0:	39 4a 18             	cmp    %ecx,0x18(%edx)
  1018e3:	0f 87 4c ff ff ff    	ja     101835 <dirlookup+0x35>
      }
    }
    brelse(bp);
  }
  return 0;
}
  1018e9:	83 c4 3c             	add    $0x3c,%esp
  1018ec:	31 c0                	xor    %eax,%eax
  1018ee:	5b                   	pop    %ebx
  1018ef:	5e                   	pop    %esi
  1018f0:	5f                   	pop    %edi
  1018f1:	5d                   	pop    %ebp
  1018f2:	c3                   	ret    
  uint off, inum;
  struct buf *bp;
  struct dirent *de;

  if(dp->type != T_DIR)
    panic("dirlookup not DIR");
  1018f3:	c7 04 24 24 6d 10 00 	movl   $0x106d24,(%esp)
  1018fa:	e8 61 f1 ff ff       	call   100a60 <panic>
  1018ff:	90                   	nop

00101900 <iunlock>:
}

// Unlock the given inode.
void
iunlock(struct inode *ip)
{
  101900:	55                   	push   %ebp
  101901:	89 e5                	mov    %esp,%ebp
  101903:	53                   	push   %ebx
  101904:	83 ec 14             	sub    $0x14,%esp
  101907:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if(ip == 0 || !(ip->flags & I_BUSY) || ip->ref < 1)
  10190a:	85 db                	test   %ebx,%ebx
  10190c:	74 36                	je     101944 <iunlock+0x44>
  10190e:	f6 43 0c 01          	testb  $0x1,0xc(%ebx)
  101912:	74 30                	je     101944 <iunlock+0x44>
  101914:	8b 43 08             	mov    0x8(%ebx),%eax
  101917:	85 c0                	test   %eax,%eax
  101919:	7e 29                	jle    101944 <iunlock+0x44>
    panic("iunlock");

  acquire(&icache.lock);
  10191b:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101922:	e8 99 29 00 00       	call   1042c0 <acquire>
  ip->flags &= ~I_BUSY;
  101927:	83 63 0c fe          	andl   $0xfffffffe,0xc(%ebx)
  wakeup(ip);
  10192b:	89 1c 24             	mov    %ebx,(%esp)
  10192e:	e8 1d 19 00 00       	call   103250 <wakeup>
  release(&icache.lock);
  101933:	c7 45 08 e0 b7 10 00 	movl   $0x10b7e0,0x8(%ebp)
}
  10193a:	83 c4 14             	add    $0x14,%esp
  10193d:	5b                   	pop    %ebx
  10193e:	5d                   	pop    %ebp
    panic("iunlock");

  acquire(&icache.lock);
  ip->flags &= ~I_BUSY;
  wakeup(ip);
  release(&icache.lock);
  10193f:	e9 2c 29 00 00       	jmp    104270 <release>
// Unlock the given inode.
void
iunlock(struct inode *ip)
{
  if(ip == 0 || !(ip->flags & I_BUSY) || ip->ref < 1)
    panic("iunlock");
  101944:	c7 04 24 36 6d 10 00 	movl   $0x106d36,(%esp)
  10194b:	e8 10 f1 ff ff       	call   100a60 <panic>

00101950 <bfree>:
}

// Free a disk block.
static void
bfree(int dev, uint b)
{
  101950:	55                   	push   %ebp
  101951:	89 e5                	mov    %esp,%ebp
  101953:	57                   	push   %edi
  101954:	56                   	push   %esi
  101955:	89 c6                	mov    %eax,%esi
  101957:	53                   	push   %ebx
  101958:	89 d3                	mov    %edx,%ebx
  10195a:	83 ec 2c             	sub    $0x2c,%esp
static void
bzero(int dev, int bno)
{
  struct buf *bp;
  
  bp = bread(dev, bno);
  10195d:	89 54 24 04          	mov    %edx,0x4(%esp)
  101961:	89 04 24             	mov    %eax,(%esp)
  101964:	e8 47 e7 ff ff       	call   1000b0 <bread>
  memset(bp->data, 0, BSIZE);
  101969:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  101970:	00 
  101971:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  101978:	00 
static void
bzero(int dev, int bno)
{
  struct buf *bp;
  
  bp = bread(dev, bno);
  101979:	89 c7                	mov    %eax,%edi
  memset(bp->data, 0, BSIZE);
  10197b:	8d 40 18             	lea    0x18(%eax),%eax
  10197e:	89 04 24             	mov    %eax,(%esp)
  101981:	e8 da 29 00 00       	call   104360 <memset>
  bwrite(bp);
  101986:	89 3c 24             	mov    %edi,(%esp)
  101989:	e8 f2 e6 ff ff       	call   100080 <bwrite>
  brelse(bp);
  10198e:	89 3c 24             	mov    %edi,(%esp)
  101991:	e8 6a e6 ff ff       	call   100000 <brelse>
  struct superblock sb;
  int bi, m;

  bzero(dev, b);

  readsb(dev, &sb);
  101996:	89 f0                	mov    %esi,%eax
  101998:	8d 55 dc             	lea    -0x24(%ebp),%edx
  10199b:	e8 90 f9 ff ff       	call   101330 <readsb>
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  1019a0:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1019a3:	89 da                	mov    %ebx,%edx
  1019a5:	c1 ea 0c             	shr    $0xc,%edx
  1019a8:	89 34 24             	mov    %esi,(%esp)
  bi = b % BPB;
  m = 1 << (bi % 8);
  1019ab:	be 01 00 00 00       	mov    $0x1,%esi
  int bi, m;

  bzero(dev, b);

  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  1019b0:	c1 e8 03             	shr    $0x3,%eax
  1019b3:	8d 44 10 03          	lea    0x3(%eax,%edx,1),%eax
  1019b7:	89 44 24 04          	mov    %eax,0x4(%esp)
  1019bb:	e8 f0 e6 ff ff       	call   1000b0 <bread>
  bi = b % BPB;
  1019c0:	89 da                	mov    %ebx,%edx
  m = 1 << (bi % 8);
  1019c2:	89 d9                	mov    %ebx,%ecx

  bzero(dev, b);

  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  bi = b % BPB;
  1019c4:	81 e2 ff 0f 00 00    	and    $0xfff,%edx
  m = 1 << (bi % 8);
  1019ca:	83 e1 07             	and    $0x7,%ecx
  if((bp->data[bi/8] & m) == 0)
  1019cd:	c1 fa 03             	sar    $0x3,%edx
  bzero(dev, b);

  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  bi = b % BPB;
  m = 1 << (bi % 8);
  1019d0:	d3 e6                	shl    %cl,%esi
  if((bp->data[bi/8] & m) == 0)
  1019d2:	0f b6 4c 10 18       	movzbl 0x18(%eax,%edx,1),%ecx
  int bi, m;

  bzero(dev, b);

  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  1019d7:	89 c7                	mov    %eax,%edi
  bi = b % BPB;
  m = 1 << (bi % 8);
  if((bp->data[bi/8] & m) == 0)
  1019d9:	0f b6 c1             	movzbl %cl,%eax
  1019dc:	85 f0                	test   %esi,%eax
  1019de:	74 22                	je     101a02 <bfree+0xb2>
    panic("freeing free block");
  bp->data[bi/8] &= ~m;  // Mark block free on disk.
  1019e0:	89 f0                	mov    %esi,%eax
  1019e2:	f7 d0                	not    %eax
  1019e4:	21 c8                	and    %ecx,%eax
  1019e6:	88 44 17 18          	mov    %al,0x18(%edi,%edx,1)
  bwrite(bp);
  1019ea:	89 3c 24             	mov    %edi,(%esp)
  1019ed:	e8 8e e6 ff ff       	call   100080 <bwrite>
  brelse(bp);
  1019f2:	89 3c 24             	mov    %edi,(%esp)
  1019f5:	e8 06 e6 ff ff       	call   100000 <brelse>
}
  1019fa:	83 c4 2c             	add    $0x2c,%esp
  1019fd:	5b                   	pop    %ebx
  1019fe:	5e                   	pop    %esi
  1019ff:	5f                   	pop    %edi
  101a00:	5d                   	pop    %ebp
  101a01:	c3                   	ret    
  readsb(dev, &sb);
  bp = bread(dev, BBLOCK(b, sb.ninodes));
  bi = b % BPB;
  m = 1 << (bi % 8);
  if((bp->data[bi/8] & m) == 0)
    panic("freeing free block");
  101a02:	c7 04 24 3e 6d 10 00 	movl   $0x106d3e,(%esp)
  101a09:	e8 52 f0 ff ff       	call   100a60 <panic>
  101a0e:	66 90                	xchg   %ax,%ax

00101a10 <iput>:
}

// Caller holds reference to unlocked ip.  Drop reference.
void
iput(struct inode *ip)
{
  101a10:	55                   	push   %ebp
  101a11:	89 e5                	mov    %esp,%ebp
  101a13:	57                   	push   %edi
  101a14:	56                   	push   %esi
  101a15:	53                   	push   %ebx
  101a16:	83 ec 2c             	sub    $0x2c,%esp
  101a19:	8b 75 08             	mov    0x8(%ebp),%esi
  acquire(&icache.lock);
  101a1c:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101a23:	e8 98 28 00 00       	call   1042c0 <acquire>
  if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){
  101a28:	8b 46 08             	mov    0x8(%esi),%eax
  101a2b:	83 f8 01             	cmp    $0x1,%eax
  101a2e:	0f 85 a1 00 00 00    	jne    101ad5 <iput+0xc5>
  101a34:	8b 56 0c             	mov    0xc(%esi),%edx
  101a37:	f6 c2 02             	test   $0x2,%dl
  101a3a:	0f 84 95 00 00 00    	je     101ad5 <iput+0xc5>
  101a40:	66 83 7e 16 00       	cmpw   $0x0,0x16(%esi)
  101a45:	0f 85 8a 00 00 00    	jne    101ad5 <iput+0xc5>
    // inode is no longer used: truncate and free inode.
    if(ip->flags & I_BUSY)
  101a4b:	f6 c2 01             	test   $0x1,%dl
  101a4e:	66 90                	xchg   %ax,%ax
  101a50:	0f 85 f8 00 00 00    	jne    101b4e <iput+0x13e>
      panic("iput busy");
    ip->flags |= I_BUSY;
  101a56:	83 ca 01             	or     $0x1,%edx
    release(&icache.lock);
  101a59:	89 f3                	mov    %esi,%ebx
  acquire(&icache.lock);
  if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){
    // inode is no longer used: truncate and free inode.
    if(ip->flags & I_BUSY)
      panic("iput busy");
    ip->flags |= I_BUSY;
  101a5b:	89 56 0c             	mov    %edx,0xc(%esi)
  release(&icache.lock);
}

// Caller holds reference to unlocked ip.  Drop reference.
void
iput(struct inode *ip)
  101a5e:	8d 7e 30             	lea    0x30(%esi),%edi
  if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){
    // inode is no longer used: truncate and free inode.
    if(ip->flags & I_BUSY)
      panic("iput busy");
    ip->flags |= I_BUSY;
    release(&icache.lock);
  101a61:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101a68:	e8 03 28 00 00       	call   104270 <release>
  101a6d:	eb 08                	jmp    101a77 <iput+0x67>
  101a6f:	90                   	nop
  uint *a;

  for(i = 0; i < NDIRECT; i++){
    if(ip->addrs[i]){
      bfree(ip->dev, ip->addrs[i]);
      ip->addrs[i] = 0;
  101a70:	83 c3 04             	add    $0x4,%ebx
{
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
  101a73:	39 fb                	cmp    %edi,%ebx
  101a75:	74 1c                	je     101a93 <iput+0x83>
    if(ip->addrs[i]){
  101a77:	8b 53 1c             	mov    0x1c(%ebx),%edx
  101a7a:	85 d2                	test   %edx,%edx
  101a7c:	74 f2                	je     101a70 <iput+0x60>
      bfree(ip->dev, ip->addrs[i]);
  101a7e:	8b 06                	mov    (%esi),%eax
  101a80:	e8 cb fe ff ff       	call   101950 <bfree>
      ip->addrs[i] = 0;
  101a85:	c7 43 1c 00 00 00 00 	movl   $0x0,0x1c(%ebx)
  101a8c:	83 c3 04             	add    $0x4,%ebx
{
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
  101a8f:	39 fb                	cmp    %edi,%ebx
  101a91:	75 e4                	jne    101a77 <iput+0x67>
      bfree(ip->dev, ip->addrs[i]);
      ip->addrs[i] = 0;
    }
  }
  
  if(ip->addrs[NDIRECT]){
  101a93:	8b 46 4c             	mov    0x4c(%esi),%eax
  101a96:	85 c0                	test   %eax,%eax
  101a98:	75 56                	jne    101af0 <iput+0xe0>
    brelse(bp);
    bfree(ip->dev, ip->addrs[NDIRECT]);
    ip->addrs[NDIRECT] = 0;
  }

  ip->size = 0;
  101a9a:	c7 46 18 00 00 00 00 	movl   $0x0,0x18(%esi)
  iupdate(ip);
  101aa1:	89 34 24             	mov    %esi,(%esp)
  101aa4:	e8 57 fb ff ff       	call   101600 <iupdate>
    if(ip->flags & I_BUSY)
      panic("iput busy");
    ip->flags |= I_BUSY;
    release(&icache.lock);
    itrunc(ip);
    ip->type = 0;
  101aa9:	66 c7 46 10 00 00    	movw   $0x0,0x10(%esi)
    iupdate(ip);
  101aaf:	89 34 24             	mov    %esi,(%esp)
  101ab2:	e8 49 fb ff ff       	call   101600 <iupdate>
    acquire(&icache.lock);
  101ab7:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101abe:	e8 fd 27 00 00       	call   1042c0 <acquire>
    ip->flags = 0;
  101ac3:	c7 46 0c 00 00 00 00 	movl   $0x0,0xc(%esi)
    wakeup(ip);
  101aca:	89 34 24             	mov    %esi,(%esp)
  101acd:	e8 7e 17 00 00       	call   103250 <wakeup>
  101ad2:	8b 46 08             	mov    0x8(%esi),%eax
  }
  ip->ref--;
  101ad5:	83 e8 01             	sub    $0x1,%eax
  101ad8:	89 46 08             	mov    %eax,0x8(%esi)
  release(&icache.lock);
  101adb:	c7 45 08 e0 b7 10 00 	movl   $0x10b7e0,0x8(%ebp)
}
  101ae2:	83 c4 2c             	add    $0x2c,%esp
  101ae5:	5b                   	pop    %ebx
  101ae6:	5e                   	pop    %esi
  101ae7:	5f                   	pop    %edi
  101ae8:	5d                   	pop    %ebp
    acquire(&icache.lock);
    ip->flags = 0;
    wakeup(ip);
  }
  ip->ref--;
  release(&icache.lock);
  101ae9:	e9 82 27 00 00       	jmp    104270 <release>
  101aee:	66 90                	xchg   %ax,%ax
      ip->addrs[i] = 0;
    }
  }
  
  if(ip->addrs[NDIRECT]){
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
  101af0:	89 44 24 04          	mov    %eax,0x4(%esp)
  101af4:	8b 06                	mov    (%esi),%eax
    a = (uint*)bp->data;
  101af6:	31 db                	xor    %ebx,%ebx
      ip->addrs[i] = 0;
    }
  }
  
  if(ip->addrs[NDIRECT]){
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
  101af8:	89 04 24             	mov    %eax,(%esp)
  101afb:	e8 b0 e5 ff ff       	call   1000b0 <bread>
    a = (uint*)bp->data;
  101b00:	89 c7                	mov    %eax,%edi
      ip->addrs[i] = 0;
    }
  }
  
  if(ip->addrs[NDIRECT]){
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
  101b02:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    a = (uint*)bp->data;
  101b05:	83 c7 18             	add    $0x18,%edi
  101b08:	31 c0                	xor    %eax,%eax
  101b0a:	eb 11                	jmp    101b1d <iput+0x10d>
  101b0c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    for(j = 0; j < NINDIRECT; j++){
  101b10:	83 c3 01             	add    $0x1,%ebx
  101b13:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  101b19:	89 d8                	mov    %ebx,%eax
  101b1b:	74 10                	je     101b2d <iput+0x11d>
      if(a[j])
  101b1d:	8b 14 87             	mov    (%edi,%eax,4),%edx
  101b20:	85 d2                	test   %edx,%edx
  101b22:	74 ec                	je     101b10 <iput+0x100>
        bfree(ip->dev, a[j]);
  101b24:	8b 06                	mov    (%esi),%eax
  101b26:	e8 25 fe ff ff       	call   101950 <bfree>
  101b2b:	eb e3                	jmp    101b10 <iput+0x100>
    }
    brelse(bp);
  101b2d:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101b30:	89 04 24             	mov    %eax,(%esp)
  101b33:	e8 c8 e4 ff ff       	call   100000 <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT]);
  101b38:	8b 56 4c             	mov    0x4c(%esi),%edx
  101b3b:	8b 06                	mov    (%esi),%eax
  101b3d:	e8 0e fe ff ff       	call   101950 <bfree>
    ip->addrs[NDIRECT] = 0;
  101b42:	c7 46 4c 00 00 00 00 	movl   $0x0,0x4c(%esi)
  101b49:	e9 4c ff ff ff       	jmp    101a9a <iput+0x8a>
{
  acquire(&icache.lock);
  if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){
    // inode is no longer used: truncate and free inode.
    if(ip->flags & I_BUSY)
      panic("iput busy");
  101b4e:	c7 04 24 51 6d 10 00 	movl   $0x106d51,(%esp)
  101b55:	e8 06 ef ff ff       	call   100a60 <panic>
  101b5a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00101b60 <dirlink>:
}

// Write a new directory entry (name, inum) into the directory dp.
int
dirlink(struct inode *dp, char *name, uint inum)
{
  101b60:	55                   	push   %ebp
  101b61:	89 e5                	mov    %esp,%ebp
  101b63:	57                   	push   %edi
  101b64:	56                   	push   %esi
  101b65:	53                   	push   %ebx
  101b66:	83 ec 2c             	sub    $0x2c,%esp
  101b69:	8b 75 08             	mov    0x8(%ebp),%esi
  int off;
  struct dirent de;
  struct inode *ip;

  // Check that name is not present.
  if((ip = dirlookup(dp, name, 0)) != 0){
  101b6c:	8b 45 0c             	mov    0xc(%ebp),%eax
  101b6f:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  101b76:	00 
  101b77:	89 34 24             	mov    %esi,(%esp)
  101b7a:	89 44 24 04          	mov    %eax,0x4(%esp)
  101b7e:	e8 7d fc ff ff       	call   101800 <dirlookup>
  101b83:	85 c0                	test   %eax,%eax
  101b85:	0f 85 89 00 00 00    	jne    101c14 <dirlink+0xb4>
    iput(ip);
    return -1;
  }

  // Look for an empty dirent.
  for(off = 0; off < dp->size; off += sizeof(de)){
  101b8b:	8b 56 18             	mov    0x18(%esi),%edx
  101b8e:	85 d2                	test   %edx,%edx
  101b90:	0f 84 8d 00 00 00    	je     101c23 <dirlink+0xc3>
  struct inode *ip;

  // Check that name is not present.
  if((ip = dirlookup(dp, name, 0)) != 0){
    iput(ip);
    return -1;
  101b96:	8d 7d d8             	lea    -0x28(%ebp),%edi
  101b99:	31 db                	xor    %ebx,%ebx
  101b9b:	eb 0b                	jmp    101ba8 <dirlink+0x48>
  101b9d:	8d 76 00             	lea    0x0(%esi),%esi
  }

  // Look for an empty dirent.
  for(off = 0; off < dp->size; off += sizeof(de)){
  101ba0:	83 c3 10             	add    $0x10,%ebx
  101ba3:	39 5e 18             	cmp    %ebx,0x18(%esi)
  101ba6:	76 24                	jbe    101bcc <dirlink+0x6c>
    if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
  101ba8:	c7 44 24 0c 10 00 00 	movl   $0x10,0xc(%esp)
  101baf:	00 
  101bb0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  101bb4:	89 7c 24 04          	mov    %edi,0x4(%esp)
  101bb8:	89 34 24             	mov    %esi,(%esp)
  101bbb:	e8 40 f9 ff ff       	call   101500 <readi>
  101bc0:	83 f8 10             	cmp    $0x10,%eax
  101bc3:	75 65                	jne    101c2a <dirlink+0xca>
      panic("dirlink read");
    if(de.inum == 0)
  101bc5:	66 83 7d d8 00       	cmpw   $0x0,-0x28(%ebp)
  101bca:	75 d4                	jne    101ba0 <dirlink+0x40>
      break;
  }

  strncpy(de.name, name, DIRSIZ);
  101bcc:	8b 45 0c             	mov    0xc(%ebp),%eax
  101bcf:	c7 44 24 08 0e 00 00 	movl   $0xe,0x8(%esp)
  101bd6:	00 
  101bd7:	89 44 24 04          	mov    %eax,0x4(%esp)
  101bdb:	8d 45 da             	lea    -0x26(%ebp),%eax
  101bde:	89 04 24             	mov    %eax,(%esp)
  101be1:	e8 ca 28 00 00       	call   1044b0 <strncpy>
  de.inum = inum;
  101be6:	8b 45 10             	mov    0x10(%ebp),%eax
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
  101be9:	c7 44 24 0c 10 00 00 	movl   $0x10,0xc(%esp)
  101bf0:	00 
  101bf1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  101bf5:	89 7c 24 04          	mov    %edi,0x4(%esp)
    if(de.inum == 0)
      break;
  }

  strncpy(de.name, name, DIRSIZ);
  de.inum = inum;
  101bf9:	66 89 45 d8          	mov    %ax,-0x28(%ebp)
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
  101bfd:	89 34 24             	mov    %esi,(%esp)
  101c00:	e8 8b fa ff ff       	call   101690 <writei>
  101c05:	83 f8 10             	cmp    $0x10,%eax
  101c08:	75 2c                	jne    101c36 <dirlink+0xd6>
    panic("dirlink");
  101c0a:	31 c0                	xor    %eax,%eax
  
  return 0;
}
  101c0c:	83 c4 2c             	add    $0x2c,%esp
  101c0f:	5b                   	pop    %ebx
  101c10:	5e                   	pop    %esi
  101c11:	5f                   	pop    %edi
  101c12:	5d                   	pop    %ebp
  101c13:	c3                   	ret    
  struct dirent de;
  struct inode *ip;

  // Check that name is not present.
  if((ip = dirlookup(dp, name, 0)) != 0){
    iput(ip);
  101c14:	89 04 24             	mov    %eax,(%esp)
  101c17:	e8 f4 fd ff ff       	call   101a10 <iput>
  101c1c:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    return -1;
  101c21:	eb e9                	jmp    101c0c <dirlink+0xac>
  }

  // Look for an empty dirent.
  for(off = 0; off < dp->size; off += sizeof(de)){
  101c23:	8d 7d d8             	lea    -0x28(%ebp),%edi
  101c26:	31 db                	xor    %ebx,%ebx
  101c28:	eb a2                	jmp    101bcc <dirlink+0x6c>
    if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
      panic("dirlink read");
  101c2a:	c7 04 24 5b 6d 10 00 	movl   $0x106d5b,(%esp)
  101c31:	e8 2a ee ff ff       	call   100a60 <panic>
  }

  strncpy(de.name, name, DIRSIZ);
  de.inum = inum;
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
    panic("dirlink");
  101c36:	c7 04 24 26 73 10 00 	movl   $0x107326,(%esp)
  101c3d:	e8 1e ee ff ff       	call   100a60 <panic>
  101c42:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  101c49:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101c50 <iunlockput>:
}

// Common idiom: unlock, then put.
void
iunlockput(struct inode *ip)
{
  101c50:	55                   	push   %ebp
  101c51:	89 e5                	mov    %esp,%ebp
  101c53:	53                   	push   %ebx
  101c54:	83 ec 14             	sub    $0x14,%esp
  101c57:	8b 5d 08             	mov    0x8(%ebp),%ebx
  iunlock(ip);
  101c5a:	89 1c 24             	mov    %ebx,(%esp)
  101c5d:	e8 9e fc ff ff       	call   101900 <iunlock>
  iput(ip);
  101c62:	89 5d 08             	mov    %ebx,0x8(%ebp)
}
  101c65:	83 c4 14             	add    $0x14,%esp
  101c68:	5b                   	pop    %ebx
  101c69:	5d                   	pop    %ebp
// Common idiom: unlock, then put.
void
iunlockput(struct inode *ip)
{
  iunlock(ip);
  iput(ip);
  101c6a:	e9 a1 fd ff ff       	jmp    101a10 <iput>
  101c6f:	90                   	nop

00101c70 <ialloc>:
static struct inode* iget(uint dev, uint inum);

// Allocate a new inode with the given type on device dev.
struct inode*
ialloc(uint dev, short type)
{
  101c70:	55                   	push   %ebp
  101c71:	89 e5                	mov    %esp,%ebp
  101c73:	57                   	push   %edi
  101c74:	56                   	push   %esi
  101c75:	53                   	push   %ebx
  101c76:	83 ec 3c             	sub    $0x3c,%esp
  101c79:	0f b7 45 0c          	movzwl 0xc(%ebp),%eax
  int inum;
  struct buf *bp;
  struct dinode *dip;
  struct superblock sb;

  readsb(dev, &sb);
  101c7d:	8d 55 dc             	lea    -0x24(%ebp),%edx
static struct inode* iget(uint dev, uint inum);

// Allocate a new inode with the given type on device dev.
struct inode*
ialloc(uint dev, short type)
{
  101c80:	66 89 45 d6          	mov    %ax,-0x2a(%ebp)
  int inum;
  struct buf *bp;
  struct dinode *dip;
  struct superblock sb;

  readsb(dev, &sb);
  101c84:	8b 45 08             	mov    0x8(%ebp),%eax
  101c87:	e8 a4 f6 ff ff       	call   101330 <readsb>
  for(inum = 1; inum < sb.ninodes; inum++){  // loop over inode blocks
  101c8c:	83 7d e4 01          	cmpl   $0x1,-0x1c(%ebp)
  101c90:	0f 86 96 00 00 00    	jbe    101d2c <ialloc+0xbc>
  101c96:	be 01 00 00 00       	mov    $0x1,%esi
  101c9b:	bb 01 00 00 00       	mov    $0x1,%ebx
  101ca0:	eb 18                	jmp    101cba <ialloc+0x4a>
  101ca2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  101ca8:	83 c3 01             	add    $0x1,%ebx
      dip->type = type;
      bwrite(bp);   // mark it allocated on the disk
      brelse(bp);
      return iget(dev, inum);
    }
    brelse(bp);
  101cab:	89 3c 24             	mov    %edi,(%esp)
  struct buf *bp;
  struct dinode *dip;
  struct superblock sb;

  readsb(dev, &sb);
  for(inum = 1; inum < sb.ninodes; inum++){  // loop over inode blocks
  101cae:	89 de                	mov    %ebx,%esi
      dip->type = type;
      bwrite(bp);   // mark it allocated on the disk
      brelse(bp);
      return iget(dev, inum);
    }
    brelse(bp);
  101cb0:	e8 4b e3 ff ff       	call   100000 <brelse>
  struct buf *bp;
  struct dinode *dip;
  struct superblock sb;

  readsb(dev, &sb);
  for(inum = 1; inum < sb.ninodes; inum++){  // loop over inode blocks
  101cb5:	39 5d e4             	cmp    %ebx,-0x1c(%ebp)
  101cb8:	76 72                	jbe    101d2c <ialloc+0xbc>
    bp = bread(dev, IBLOCK(inum));
  101cba:	89 f0                	mov    %esi,%eax
  101cbc:	c1 e8 03             	shr    $0x3,%eax
  101cbf:	83 c0 02             	add    $0x2,%eax
  101cc2:	89 44 24 04          	mov    %eax,0x4(%esp)
  101cc6:	8b 45 08             	mov    0x8(%ebp),%eax
  101cc9:	89 04 24             	mov    %eax,(%esp)
  101ccc:	e8 df e3 ff ff       	call   1000b0 <bread>
  101cd1:	89 c7                	mov    %eax,%edi
    dip = (struct dinode*)bp->data + inum%IPB;
  101cd3:	89 f0                	mov    %esi,%eax
  101cd5:	83 e0 07             	and    $0x7,%eax
  101cd8:	c1 e0 06             	shl    $0x6,%eax
  101cdb:	8d 54 07 18          	lea    0x18(%edi,%eax,1),%edx
    if(dip->type == 0){  // a free inode
  101cdf:	66 83 3a 00          	cmpw   $0x0,(%edx)
  101ce3:	75 c3                	jne    101ca8 <ialloc+0x38>
      memset(dip, 0, sizeof(*dip));
  101ce5:	89 14 24             	mov    %edx,(%esp)
  101ce8:	89 55 d0             	mov    %edx,-0x30(%ebp)
  101ceb:	c7 44 24 08 40 00 00 	movl   $0x40,0x8(%esp)
  101cf2:	00 
  101cf3:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  101cfa:	00 
  101cfb:	e8 60 26 00 00       	call   104360 <memset>
      dip->type = type;
  101d00:	8b 55 d0             	mov    -0x30(%ebp),%edx
  101d03:	0f b7 45 d6          	movzwl -0x2a(%ebp),%eax
  101d07:	66 89 02             	mov    %ax,(%edx)
      bwrite(bp);   // mark it allocated on the disk
  101d0a:	89 3c 24             	mov    %edi,(%esp)
  101d0d:	e8 6e e3 ff ff       	call   100080 <bwrite>
      brelse(bp);
  101d12:	89 3c 24             	mov    %edi,(%esp)
  101d15:	e8 e6 e2 ff ff       	call   100000 <brelse>
      return iget(dev, inum);
  101d1a:	8b 45 08             	mov    0x8(%ebp),%eax
  101d1d:	89 f2                	mov    %esi,%edx
  101d1f:	e8 4c f5 ff ff       	call   101270 <iget>
    }
    brelse(bp);
  }
  panic("ialloc: no inodes");
}
  101d24:	83 c4 3c             	add    $0x3c,%esp
  101d27:	5b                   	pop    %ebx
  101d28:	5e                   	pop    %esi
  101d29:	5f                   	pop    %edi
  101d2a:	5d                   	pop    %ebp
  101d2b:	c3                   	ret    
      brelse(bp);
      return iget(dev, inum);
    }
    brelse(bp);
  }
  panic("ialloc: no inodes");
  101d2c:	c7 04 24 68 6d 10 00 	movl   $0x106d68,(%esp)
  101d33:	e8 28 ed ff ff       	call   100a60 <panic>
  101d38:	90                   	nop
  101d39:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00101d40 <ilock>:
}

// Lock the given inode.
void
ilock(struct inode *ip)
{
  101d40:	55                   	push   %ebp
  101d41:	89 e5                	mov    %esp,%ebp
  101d43:	56                   	push   %esi
  101d44:	53                   	push   %ebx
  101d45:	83 ec 10             	sub    $0x10,%esp
  101d48:	8b 5d 08             	mov    0x8(%ebp),%ebx
  struct buf *bp;
  struct dinode *dip;

  if(ip == 0 || ip->ref < 1)
  101d4b:	85 db                	test   %ebx,%ebx
  101d4d:	0f 84 e5 00 00 00    	je     101e38 <ilock+0xf8>
  101d53:	8b 4b 08             	mov    0x8(%ebx),%ecx
  101d56:	85 c9                	test   %ecx,%ecx
  101d58:	0f 8e da 00 00 00    	jle    101e38 <ilock+0xf8>
    panic("ilock");

  acquire(&icache.lock);
  101d5e:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101d65:	e8 56 25 00 00       	call   1042c0 <acquire>
  while(ip->flags & I_BUSY)
  101d6a:	8b 43 0c             	mov    0xc(%ebx),%eax
  101d6d:	a8 01                	test   $0x1,%al
  101d6f:	74 1e                	je     101d8f <ilock+0x4f>
  101d71:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    sleep(ip, &icache.lock);
  101d78:	c7 44 24 04 e0 b7 10 	movl   $0x10b7e0,0x4(%esp)
  101d7f:	00 
  101d80:	89 1c 24             	mov    %ebx,(%esp)
  101d83:	e8 f8 15 00 00       	call   103380 <sleep>

  if(ip == 0 || ip->ref < 1)
    panic("ilock");

  acquire(&icache.lock);
  while(ip->flags & I_BUSY)
  101d88:	8b 43 0c             	mov    0xc(%ebx),%eax
  101d8b:	a8 01                	test   $0x1,%al
  101d8d:	75 e9                	jne    101d78 <ilock+0x38>
    sleep(ip, &icache.lock);
  ip->flags |= I_BUSY;
  101d8f:	83 c8 01             	or     $0x1,%eax
  101d92:	89 43 0c             	mov    %eax,0xc(%ebx)
  release(&icache.lock);
  101d95:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  101d9c:	e8 cf 24 00 00       	call   104270 <release>

  if(!(ip->flags & I_VALID)){
  101da1:	f6 43 0c 02          	testb  $0x2,0xc(%ebx)
  101da5:	74 09                	je     101db0 <ilock+0x70>
    brelse(bp);
    ip->flags |= I_VALID;
    if(ip->type == 0)
      panic("ilock: no type");
  }
}
  101da7:	83 c4 10             	add    $0x10,%esp
  101daa:	5b                   	pop    %ebx
  101dab:	5e                   	pop    %esi
  101dac:	5d                   	pop    %ebp
  101dad:	c3                   	ret    
  101dae:	66 90                	xchg   %ax,%ax
    sleep(ip, &icache.lock);
  ip->flags |= I_BUSY;
  release(&icache.lock);

  if(!(ip->flags & I_VALID)){
    bp = bread(ip->dev, IBLOCK(ip->inum));
  101db0:	8b 43 04             	mov    0x4(%ebx),%eax
  101db3:	c1 e8 03             	shr    $0x3,%eax
  101db6:	83 c0 02             	add    $0x2,%eax
  101db9:	89 44 24 04          	mov    %eax,0x4(%esp)
  101dbd:	8b 03                	mov    (%ebx),%eax
  101dbf:	89 04 24             	mov    %eax,(%esp)
  101dc2:	e8 e9 e2 ff ff       	call   1000b0 <bread>
  101dc7:	89 c6                	mov    %eax,%esi
    dip = (struct dinode*)bp->data + ip->inum%IPB;
  101dc9:	8b 43 04             	mov    0x4(%ebx),%eax
  101dcc:	83 e0 07             	and    $0x7,%eax
  101dcf:	c1 e0 06             	shl    $0x6,%eax
  101dd2:	8d 44 06 18          	lea    0x18(%esi,%eax,1),%eax
    ip->type = dip->type;
  101dd6:	0f b7 10             	movzwl (%eax),%edx
  101dd9:	66 89 53 10          	mov    %dx,0x10(%ebx)
    ip->major = dip->major;
  101ddd:	0f b7 50 02          	movzwl 0x2(%eax),%edx
  101de1:	66 89 53 12          	mov    %dx,0x12(%ebx)
    ip->minor = dip->minor;
  101de5:	0f b7 50 04          	movzwl 0x4(%eax),%edx
  101de9:	66 89 53 14          	mov    %dx,0x14(%ebx)
    ip->nlink = dip->nlink;
  101ded:	0f b7 50 06          	movzwl 0x6(%eax),%edx
  101df1:	66 89 53 16          	mov    %dx,0x16(%ebx)
    ip->size = dip->size;
  101df5:	8b 50 08             	mov    0x8(%eax),%edx
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
  101df8:	83 c0 0c             	add    $0xc,%eax
    dip = (struct dinode*)bp->data + ip->inum%IPB;
    ip->type = dip->type;
    ip->major = dip->major;
    ip->minor = dip->minor;
    ip->nlink = dip->nlink;
    ip->size = dip->size;
  101dfb:	89 53 18             	mov    %edx,0x18(%ebx)
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
  101dfe:	89 44 24 04          	mov    %eax,0x4(%esp)
  101e02:	8d 43 1c             	lea    0x1c(%ebx),%eax
  101e05:	c7 44 24 08 34 00 00 	movl   $0x34,0x8(%esp)
  101e0c:	00 
  101e0d:	89 04 24             	mov    %eax,(%esp)
  101e10:	e8 cb 25 00 00       	call   1043e0 <memmove>
    brelse(bp);
  101e15:	89 34 24             	mov    %esi,(%esp)
  101e18:	e8 e3 e1 ff ff       	call   100000 <brelse>
    ip->flags |= I_VALID;
  101e1d:	83 4b 0c 02          	orl    $0x2,0xc(%ebx)
    if(ip->type == 0)
  101e21:	66 83 7b 10 00       	cmpw   $0x0,0x10(%ebx)
  101e26:	0f 85 7b ff ff ff    	jne    101da7 <ilock+0x67>
      panic("ilock: no type");
  101e2c:	c7 04 24 80 6d 10 00 	movl   $0x106d80,(%esp)
  101e33:	e8 28 ec ff ff       	call   100a60 <panic>
{
  struct buf *bp;
  struct dinode *dip;

  if(ip == 0 || ip->ref < 1)
    panic("ilock");
  101e38:	c7 04 24 7a 6d 10 00 	movl   $0x106d7a,(%esp)
  101e3f:	e8 1c ec ff ff       	call   100a60 <panic>
  101e44:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  101e4a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00101e50 <namex>:
// Look up and return the inode for a path name.
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
static struct inode*
namex(char *path, int nameiparent, char *name)
{
  101e50:	55                   	push   %ebp
  101e51:	89 e5                	mov    %esp,%ebp
  101e53:	57                   	push   %edi
  101e54:	56                   	push   %esi
  101e55:	53                   	push   %ebx
  101e56:	89 c3                	mov    %eax,%ebx
  101e58:	83 ec 2c             	sub    $0x2c,%esp
  101e5b:	89 55 e0             	mov    %edx,-0x20(%ebp)
  101e5e:	89 4d e4             	mov    %ecx,-0x1c(%ebp)
  struct inode *ip, *next;

  if(*path == '/')
  101e61:	80 38 2f             	cmpb   $0x2f,(%eax)
  101e64:	0f 84 14 01 00 00    	je     101f7e <namex+0x12e>
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(proc->cwd);
  101e6a:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  101e70:	8b 40 68             	mov    0x68(%eax),%eax
  101e73:	89 04 24             	mov    %eax,(%esp)
  101e76:	e8 c5 f3 ff ff       	call   101240 <idup>
  101e7b:	89 c7                	mov    %eax,%edi
  101e7d:	eb 04                	jmp    101e83 <namex+0x33>
  101e7f:	90                   	nop
{
  char *s;
  int len;

  while(*path == '/')
    path++;
  101e80:	83 c3 01             	add    $0x1,%ebx
skipelem(char *path, char *name)
{
  char *s;
  int len;

  while(*path == '/')
  101e83:	0f b6 03             	movzbl (%ebx),%eax
  101e86:	3c 2f                	cmp    $0x2f,%al
  101e88:	74 f6                	je     101e80 <namex+0x30>
    path++;
  if(*path == 0)
  101e8a:	84 c0                	test   %al,%al
  101e8c:	75 1a                	jne    101ea8 <namex+0x58>
      return 0;
    }
    iunlockput(ip);
    ip = next;
  }
  if(nameiparent){
  101e8e:	8b 5d e0             	mov    -0x20(%ebp),%ebx
  101e91:	85 db                	test   %ebx,%ebx
  101e93:	0f 85 0d 01 00 00    	jne    101fa6 <namex+0x156>
    iput(ip);
    return 0;
  }
  return ip;
}
  101e99:	83 c4 2c             	add    $0x2c,%esp
  101e9c:	89 f8                	mov    %edi,%eax
  101e9e:	5b                   	pop    %ebx
  101e9f:	5e                   	pop    %esi
  101ea0:	5f                   	pop    %edi
  101ea1:	5d                   	pop    %ebp
  101ea2:	c3                   	ret    
  101ea3:	90                   	nop
  101ea4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  while(*path == '/')
    path++;
  if(*path == 0)
    return 0;
  s = path;
  while(*path != '/' && *path != 0)
  101ea8:	3c 2f                	cmp    $0x2f,%al
  101eaa:	0f 84 94 00 00 00    	je     101f44 <namex+0xf4>
  101eb0:	89 de                	mov    %ebx,%esi
  101eb2:	eb 08                	jmp    101ebc <namex+0x6c>
  101eb4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  101eb8:	3c 2f                	cmp    $0x2f,%al
  101eba:	74 0a                	je     101ec6 <namex+0x76>
    path++;
  101ebc:	83 c6 01             	add    $0x1,%esi
  while(*path == '/')
    path++;
  if(*path == 0)
    return 0;
  s = path;
  while(*path != '/' && *path != 0)
  101ebf:	0f b6 06             	movzbl (%esi),%eax
  101ec2:	84 c0                	test   %al,%al
  101ec4:	75 f2                	jne    101eb8 <namex+0x68>
  101ec6:	89 f2                	mov    %esi,%edx
  101ec8:	29 da                	sub    %ebx,%edx
    path++;
  len = path - s;
  if(len >= DIRSIZ)
  101eca:	83 fa 0d             	cmp    $0xd,%edx
  101ecd:	7e 79                	jle    101f48 <namex+0xf8>
    memmove(name, s, DIRSIZ);
  101ecf:	c7 44 24 08 0e 00 00 	movl   $0xe,0x8(%esp)
  101ed6:	00 
  101ed7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  101edb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101ede:	89 04 24             	mov    %eax,(%esp)
  101ee1:	e8 fa 24 00 00       	call   1043e0 <memmove>
  101ee6:	eb 03                	jmp    101eeb <namex+0x9b>
  else {
    memmove(name, s, len);
    name[len] = 0;
  }
  while(*path == '/')
    path++;
  101ee8:	83 c6 01             	add    $0x1,%esi
    memmove(name, s, DIRSIZ);
  else {
    memmove(name, s, len);
    name[len] = 0;
  }
  while(*path == '/')
  101eeb:	80 3e 2f             	cmpb   $0x2f,(%esi)
  101eee:	74 f8                	je     101ee8 <namex+0x98>
  if(*path == '/')
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(proc->cwd);

  while((path = skipelem(path, name)) != 0){
  101ef0:	85 f6                	test   %esi,%esi
  101ef2:	74 9a                	je     101e8e <namex+0x3e>
    ilock(ip);
  101ef4:	89 3c 24             	mov    %edi,(%esp)
  101ef7:	e8 44 fe ff ff       	call   101d40 <ilock>
    if(ip->type != T_DIR){
  101efc:	66 83 7f 10 01       	cmpw   $0x1,0x10(%edi)
  101f01:	75 67                	jne    101f6a <namex+0x11a>
      iunlockput(ip);
      return 0;
    }
    if(nameiparent && *path == '\0'){
  101f03:	8b 45 e0             	mov    -0x20(%ebp),%eax
  101f06:	85 c0                	test   %eax,%eax
  101f08:	74 0c                	je     101f16 <namex+0xc6>
  101f0a:	80 3e 00             	cmpb   $0x0,(%esi)
  101f0d:	8d 76 00             	lea    0x0(%esi),%esi
  101f10:	0f 84 7e 00 00 00    	je     101f94 <namex+0x144>
      // Stop one level early.
      iunlock(ip);
      return ip;
    }
    if((next = dirlookup(ip, name, 0)) == 0){
  101f16:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  101f1d:	00 
  101f1e:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101f21:	89 3c 24             	mov    %edi,(%esp)
  101f24:	89 44 24 04          	mov    %eax,0x4(%esp)
  101f28:	e8 d3 f8 ff ff       	call   101800 <dirlookup>
  101f2d:	85 c0                	test   %eax,%eax
  101f2f:	89 c3                	mov    %eax,%ebx
  101f31:	74 37                	je     101f6a <namex+0x11a>
      iunlockput(ip);
      return 0;
    }
    iunlockput(ip);
  101f33:	89 3c 24             	mov    %edi,(%esp)
  101f36:	89 df                	mov    %ebx,%edi
  101f38:	89 f3                	mov    %esi,%ebx
  101f3a:	e8 11 fd ff ff       	call   101c50 <iunlockput>
  101f3f:	e9 3f ff ff ff       	jmp    101e83 <namex+0x33>
    memmove(name, s, DIRSIZ);
  else {
    memmove(name, s, len);
    name[len] = 0;
  }
  while(*path == '/')
  101f44:	89 de                	mov    %ebx,%esi
  101f46:	31 d2                	xor    %edx,%edx
    path++;
  len = path - s;
  if(len >= DIRSIZ)
    memmove(name, s, DIRSIZ);
  else {
    memmove(name, s, len);
  101f48:	89 54 24 08          	mov    %edx,0x8(%esp)
  101f4c:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  101f50:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101f53:	89 04 24             	mov    %eax,(%esp)
  101f56:	89 55 dc             	mov    %edx,-0x24(%ebp)
  101f59:	e8 82 24 00 00       	call   1043e0 <memmove>
    name[len] = 0;
  101f5e:	8b 55 dc             	mov    -0x24(%ebp),%edx
  101f61:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  101f64:	c6 04 10 00          	movb   $0x0,(%eax,%edx,1)
  101f68:	eb 81                	jmp    101eeb <namex+0x9b>
      // Stop one level early.
      iunlock(ip);
      return ip;
    }
    if((next = dirlookup(ip, name, 0)) == 0){
      iunlockput(ip);
  101f6a:	89 3c 24             	mov    %edi,(%esp)
  101f6d:	31 ff                	xor    %edi,%edi
  101f6f:	e8 dc fc ff ff       	call   101c50 <iunlockput>
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
  101f74:	83 c4 2c             	add    $0x2c,%esp
  101f77:	89 f8                	mov    %edi,%eax
  101f79:	5b                   	pop    %ebx
  101f7a:	5e                   	pop    %esi
  101f7b:	5f                   	pop    %edi
  101f7c:	5d                   	pop    %ebp
  101f7d:	c3                   	ret    
namex(char *path, int nameiparent, char *name)
{
  struct inode *ip, *next;

  if(*path == '/')
    ip = iget(ROOTDEV, ROOTINO);
  101f7e:	ba 01 00 00 00       	mov    $0x1,%edx
  101f83:	b8 01 00 00 00       	mov    $0x1,%eax
  101f88:	e8 e3 f2 ff ff       	call   101270 <iget>
  101f8d:	89 c7                	mov    %eax,%edi
  101f8f:	e9 ef fe ff ff       	jmp    101e83 <namex+0x33>
      iunlockput(ip);
      return 0;
    }
    if(nameiparent && *path == '\0'){
      // Stop one level early.
      iunlock(ip);
  101f94:	89 3c 24             	mov    %edi,(%esp)
  101f97:	e8 64 f9 ff ff       	call   101900 <iunlock>
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
  101f9c:	83 c4 2c             	add    $0x2c,%esp
  101f9f:	89 f8                	mov    %edi,%eax
  101fa1:	5b                   	pop    %ebx
  101fa2:	5e                   	pop    %esi
  101fa3:	5f                   	pop    %edi
  101fa4:	5d                   	pop    %ebp
  101fa5:	c3                   	ret    
    }
    iunlockput(ip);
    ip = next;
  }
  if(nameiparent){
    iput(ip);
  101fa6:	89 3c 24             	mov    %edi,(%esp)
  101fa9:	31 ff                	xor    %edi,%edi
  101fab:	e8 60 fa ff ff       	call   101a10 <iput>
    return 0;
  101fb0:	e9 e4 fe ff ff       	jmp    101e99 <namex+0x49>
  101fb5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  101fb9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101fc0 <nameiparent>:
  return namex(path, 0, name);
}

struct inode*
nameiparent(char *path, char *name)
{
  101fc0:	55                   	push   %ebp
  return namex(path, 1, name);
  101fc1:	ba 01 00 00 00       	mov    $0x1,%edx
  return namex(path, 0, name);
}

struct inode*
nameiparent(char *path, char *name)
{
  101fc6:	89 e5                	mov    %esp,%ebp
  101fc8:	83 ec 08             	sub    $0x8,%esp
  return namex(path, 1, name);
  101fcb:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  101fce:	8b 45 08             	mov    0x8(%ebp),%eax
}
  101fd1:	c9                   	leave  
}

struct inode*
nameiparent(char *path, char *name)
{
  return namex(path, 1, name);
  101fd2:	e9 79 fe ff ff       	jmp    101e50 <namex>
  101fd7:	89 f6                	mov    %esi,%esi
  101fd9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00101fe0 <namei>:
  return ip;
}

struct inode*
namei(char *path)
{
  101fe0:	55                   	push   %ebp
  char name[DIRSIZ];
  return namex(path, 0, name);
  101fe1:	31 d2                	xor    %edx,%edx
  return ip;
}

struct inode*
namei(char *path)
{
  101fe3:	89 e5                	mov    %esp,%ebp
  101fe5:	83 ec 18             	sub    $0x18,%esp
  char name[DIRSIZ];
  return namex(path, 0, name);
  101fe8:	8b 45 08             	mov    0x8(%ebp),%eax
  101feb:	8d 4d ea             	lea    -0x16(%ebp),%ecx
  101fee:	e8 5d fe ff ff       	call   101e50 <namex>
}
  101ff3:	c9                   	leave  
  101ff4:	c3                   	ret    
  101ff5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  101ff9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00102000 <iinit>:
  struct inode inode[NINODE];
} icache;

void
iinit(void)
{
  102000:	55                   	push   %ebp
  102001:	89 e5                	mov    %esp,%ebp
  102003:	83 ec 18             	sub    $0x18,%esp
  initlock(&icache.lock, "icache");
  102006:	c7 44 24 04 8f 6d 10 	movl   $0x106d8f,0x4(%esp)
  10200d:	00 
  10200e:	c7 04 24 e0 b7 10 00 	movl   $0x10b7e0,(%esp)
  102015:	e8 16 21 00 00       	call   104130 <initlock>
}
  10201a:	c9                   	leave  
  10201b:	c3                   	ret    
  10201c:	90                   	nop
  10201d:	90                   	nop
  10201e:	90                   	nop
  10201f:	90                   	nop

00102020 <idestart>:
}

// Start the request for b.  Caller must hold idelock.
static void
idestart(struct buf *b)
{
  102020:	55                   	push   %ebp
  102021:	89 e5                	mov    %esp,%ebp
  102023:	56                   	push   %esi
  102024:	89 c6                	mov    %eax,%esi
  102026:	83 ec 14             	sub    $0x14,%esp
  if(b == 0)
  102029:	85 c0                	test   %eax,%eax
  10202b:	0f 84 8d 00 00 00    	je     1020be <idestart+0x9e>
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  102031:	ba f7 01 00 00       	mov    $0x1f7,%edx
  102036:	66 90                	xchg   %ax,%ax
  102038:	ec                   	in     (%dx),%al
static int
idewait(int checkerr)
{
  int r;

  while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 
  102039:	25 c0 00 00 00       	and    $0xc0,%eax
  10203e:	83 f8 40             	cmp    $0x40,%eax
  102041:	75 f5                	jne    102038 <idestart+0x18>
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  102043:	ba f6 03 00 00       	mov    $0x3f6,%edx
  102048:	31 c0                	xor    %eax,%eax
  10204a:	ee                   	out    %al,(%dx)
  10204b:	ba f2 01 00 00       	mov    $0x1f2,%edx
  102050:	b8 01 00 00 00       	mov    $0x1,%eax
  102055:	ee                   	out    %al,(%dx)
    panic("idestart");

  idewait(0);
  outb(0x3f6, 0);  // generate interrupt
  outb(0x1f2, 1);  // number of sectors
  outb(0x1f3, b->sector & 0xff);
  102056:	8b 4e 08             	mov    0x8(%esi),%ecx
  102059:	b2 f3                	mov    $0xf3,%dl
  10205b:	89 c8                	mov    %ecx,%eax
  10205d:	ee                   	out    %al,(%dx)
  10205e:	89 c8                	mov    %ecx,%eax
  102060:	b2 f4                	mov    $0xf4,%dl
  102062:	c1 e8 08             	shr    $0x8,%eax
  102065:	ee                   	out    %al,(%dx)
  102066:	89 c8                	mov    %ecx,%eax
  102068:	b2 f5                	mov    $0xf5,%dl
  10206a:	c1 e8 10             	shr    $0x10,%eax
  10206d:	ee                   	out    %al,(%dx)
  10206e:	8b 46 04             	mov    0x4(%esi),%eax
  102071:	c1 e9 18             	shr    $0x18,%ecx
  102074:	b2 f6                	mov    $0xf6,%dl
  102076:	83 e1 0f             	and    $0xf,%ecx
  102079:	83 e0 01             	and    $0x1,%eax
  10207c:	c1 e0 04             	shl    $0x4,%eax
  10207f:	09 c8                	or     %ecx,%eax
  102081:	83 c8 e0             	or     $0xffffffe0,%eax
  102084:	ee                   	out    %al,(%dx)
  outb(0x1f4, (b->sector >> 8) & 0xff);
  outb(0x1f5, (b->sector >> 16) & 0xff);
  outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((b->sector>>24)&0x0f));
  if(b->flags & B_DIRTY){
  102085:	f6 06 04             	testb  $0x4,(%esi)
  102088:	75 16                	jne    1020a0 <idestart+0x80>
  10208a:	ba f7 01 00 00       	mov    $0x1f7,%edx
  10208f:	b8 20 00 00 00       	mov    $0x20,%eax
  102094:	ee                   	out    %al,(%dx)
    outb(0x1f7, IDE_CMD_WRITE);
    outsl(0x1f0, b->data, 512/4);
  } else {
    outb(0x1f7, IDE_CMD_READ);
  }
}
  102095:	83 c4 14             	add    $0x14,%esp
  102098:	5e                   	pop    %esi
  102099:	5d                   	pop    %ebp
  10209a:	c3                   	ret    
  10209b:	90                   	nop
  10209c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1020a0:	b2 f7                	mov    $0xf7,%dl
  1020a2:	b8 30 00 00 00       	mov    $0x30,%eax
  1020a7:	ee                   	out    %al,(%dx)
}

static inline void
outsl(int port, const void *addr, int cnt)
{
  asm volatile("cld; rep outsl" :
  1020a8:	b9 80 00 00 00       	mov    $0x80,%ecx
  1020ad:	83 c6 18             	add    $0x18,%esi
  1020b0:	ba f0 01 00 00       	mov    $0x1f0,%edx
  1020b5:	fc                   	cld    
  1020b6:	f3 6f                	rep outsl %ds:(%esi),(%dx)
  1020b8:	83 c4 14             	add    $0x14,%esp
  1020bb:	5e                   	pop    %esi
  1020bc:	5d                   	pop    %ebp
  1020bd:	c3                   	ret    
// Start the request for b.  Caller must hold idelock.
static void
idestart(struct buf *b)
{
  if(b == 0)
    panic("idestart");
  1020be:	c7 04 24 96 6d 10 00 	movl   $0x106d96,(%esp)
  1020c5:	e8 96 e9 ff ff       	call   100a60 <panic>
  1020ca:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

001020d0 <iderw>:
// Sync buf with disk. 
// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.
// Else if B_VALID is not set, read buf from disk, set B_VALID.
void
iderw(struct buf *b)
{
  1020d0:	55                   	push   %ebp
  1020d1:	89 e5                	mov    %esp,%ebp
  1020d3:	53                   	push   %ebx
  1020d4:	83 ec 14             	sub    $0x14,%esp
  1020d7:	8b 5d 08             	mov    0x8(%ebp),%ebx
  struct buf **pp;

  if(!(b->flags & B_BUSY))
  1020da:	8b 03                	mov    (%ebx),%eax
  1020dc:	a8 01                	test   $0x1,%al
  1020de:	0f 84 90 00 00 00    	je     102174 <iderw+0xa4>
    panic("iderw: buf not busy");
  if((b->flags & (B_VALID|B_DIRTY)) == B_VALID)
  1020e4:	83 e0 06             	and    $0x6,%eax
  1020e7:	83 f8 02             	cmp    $0x2,%eax
  1020ea:	0f 84 9c 00 00 00    	je     10218c <iderw+0xbc>
    panic("iderw: nothing to do");
  if(b->dev != 0 && !havedisk1)
  1020f0:	8b 53 04             	mov    0x4(%ebx),%edx
  1020f3:	85 d2                	test   %edx,%edx
  1020f5:	74 0d                	je     102104 <iderw+0x34>
  1020f7:	a1 b8 95 10 00       	mov    0x1095b8,%eax
  1020fc:	85 c0                	test   %eax,%eax
  1020fe:	0f 84 7c 00 00 00    	je     102180 <iderw+0xb0>
    panic("idrw: ide disk 1 not present");

  acquire(&idelock);
  102104:	c7 04 24 80 95 10 00 	movl   $0x109580,(%esp)
  10210b:	e8 b0 21 00 00       	call   1042c0 <acquire>

  // Append b to idequeue.
  b->qnext = 0;
  for(pp=&idequeue; *pp; pp=&(*pp)->qnext)
  102110:	ba b4 95 10 00       	mov    $0x1095b4,%edx
    panic("idrw: ide disk 1 not present");

  acquire(&idelock);

  // Append b to idequeue.
  b->qnext = 0;
  102115:	c7 43 14 00 00 00 00 	movl   $0x0,0x14(%ebx)
  10211c:	a1 b4 95 10 00       	mov    0x1095b4,%eax
  for(pp=&idequeue; *pp; pp=&(*pp)->qnext)
  102121:	85 c0                	test   %eax,%eax
  102123:	74 0d                	je     102132 <iderw+0x62>
  102125:	8d 76 00             	lea    0x0(%esi),%esi
  102128:	8d 50 14             	lea    0x14(%eax),%edx
  10212b:	8b 40 14             	mov    0x14(%eax),%eax
  10212e:	85 c0                	test   %eax,%eax
  102130:	75 f6                	jne    102128 <iderw+0x58>
    ;
  *pp = b;
  102132:	89 1a                	mov    %ebx,(%edx)
  
  // Start disk if necessary.
  if(idequeue == b)
  102134:	39 1d b4 95 10 00    	cmp    %ebx,0x1095b4
  10213a:	75 14                	jne    102150 <iderw+0x80>
  10213c:	eb 2d                	jmp    10216b <iderw+0x9b>
  10213e:	66 90                	xchg   %ax,%ax
    idestart(b);
  
  // Wait for request to finish.
  // Assuming will not sleep too long: ignore proc->killed.
  while((b->flags & (B_VALID|B_DIRTY)) != B_VALID) {
    sleep(b, &idelock);
  102140:	c7 44 24 04 80 95 10 	movl   $0x109580,0x4(%esp)
  102147:	00 
  102148:	89 1c 24             	mov    %ebx,(%esp)
  10214b:	e8 30 12 00 00       	call   103380 <sleep>
  if(idequeue == b)
    idestart(b);
  
  // Wait for request to finish.
  // Assuming will not sleep too long: ignore proc->killed.
  while((b->flags & (B_VALID|B_DIRTY)) != B_VALID) {
  102150:	8b 03                	mov    (%ebx),%eax
  102152:	83 e0 06             	and    $0x6,%eax
  102155:	83 f8 02             	cmp    $0x2,%eax
  102158:	75 e6                	jne    102140 <iderw+0x70>
    sleep(b, &idelock);
  }

  release(&idelock);
  10215a:	c7 45 08 80 95 10 00 	movl   $0x109580,0x8(%ebp)
}
  102161:	83 c4 14             	add    $0x14,%esp
  102164:	5b                   	pop    %ebx
  102165:	5d                   	pop    %ebp
  // Assuming will not sleep too long: ignore proc->killed.
  while((b->flags & (B_VALID|B_DIRTY)) != B_VALID) {
    sleep(b, &idelock);
  }

  release(&idelock);
  102166:	e9 05 21 00 00       	jmp    104270 <release>
    ;
  *pp = b;
  
  // Start disk if necessary.
  if(idequeue == b)
    idestart(b);
  10216b:	89 d8                	mov    %ebx,%eax
  10216d:	e8 ae fe ff ff       	call   102020 <idestart>
  102172:	eb dc                	jmp    102150 <iderw+0x80>
iderw(struct buf *b)
{
  struct buf **pp;

  if(!(b->flags & B_BUSY))
    panic("iderw: buf not busy");
  102174:	c7 04 24 9f 6d 10 00 	movl   $0x106d9f,(%esp)
  10217b:	e8 e0 e8 ff ff       	call   100a60 <panic>
  if((b->flags & (B_VALID|B_DIRTY)) == B_VALID)
    panic("iderw: nothing to do");
  if(b->dev != 0 && !havedisk1)
    panic("idrw: ide disk 1 not present");
  102180:	c7 04 24 c8 6d 10 00 	movl   $0x106dc8,(%esp)
  102187:	e8 d4 e8 ff ff       	call   100a60 <panic>
  struct buf **pp;

  if(!(b->flags & B_BUSY))
    panic("iderw: buf not busy");
  if((b->flags & (B_VALID|B_DIRTY)) == B_VALID)
    panic("iderw: nothing to do");
  10218c:	c7 04 24 b3 6d 10 00 	movl   $0x106db3,(%esp)
  102193:	e8 c8 e8 ff ff       	call   100a60 <panic>
  102198:	90                   	nop
  102199:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

001021a0 <ideintr>:
}

// Interrupt handler.
void
ideintr(void)
{
  1021a0:	55                   	push   %ebp
  1021a1:	89 e5                	mov    %esp,%ebp
  1021a3:	57                   	push   %edi
  1021a4:	53                   	push   %ebx
  1021a5:	83 ec 10             	sub    $0x10,%esp
  struct buf *b;

  // Take first buffer off queue.
  acquire(&idelock);
  1021a8:	c7 04 24 80 95 10 00 	movl   $0x109580,(%esp)
  1021af:	e8 0c 21 00 00       	call   1042c0 <acquire>
  if((b = idequeue) == 0){
  1021b4:	8b 1d b4 95 10 00    	mov    0x1095b4,%ebx
  1021ba:	85 db                	test   %ebx,%ebx
  1021bc:	74 7a                	je     102238 <ideintr+0x98>
    release(&idelock);
    cprintf("Spurious IDE interrupt.\n");
    return;
  }
  idequeue = b->qnext;
  1021be:	8b 43 14             	mov    0x14(%ebx),%eax
  1021c1:	a3 b4 95 10 00       	mov    %eax,0x1095b4

  // Read data if needed.
  if(!(b->flags & B_DIRTY) && idewait(1) >= 0)
  1021c6:	8b 0b                	mov    (%ebx),%ecx
  1021c8:	f6 c1 04             	test   $0x4,%cl
  1021cb:	74 33                	je     102200 <ideintr+0x60>
    insl(0x1f0, b->data, 512/4);
  
  // Wake process waiting for this buf.
  b->flags |= B_VALID;
  b->flags &= ~B_DIRTY;
  1021cd:	83 c9 02             	or     $0x2,%ecx
  1021d0:	83 e1 fb             	and    $0xfffffffb,%ecx
  1021d3:	89 0b                	mov    %ecx,(%ebx)
  wakeup(b);
  1021d5:	89 1c 24             	mov    %ebx,(%esp)
  1021d8:	e8 73 10 00 00       	call   103250 <wakeup>
  
  // Start disk on next buf in queue.
  if(idequeue != 0)
  1021dd:	a1 b4 95 10 00       	mov    0x1095b4,%eax
  1021e2:	85 c0                	test   %eax,%eax
  1021e4:	74 05                	je     1021eb <ideintr+0x4b>
    idestart(idequeue);
  1021e6:	e8 35 fe ff ff       	call   102020 <idestart>

  release(&idelock);
  1021eb:	c7 04 24 80 95 10 00 	movl   $0x109580,(%esp)
  1021f2:	e8 79 20 00 00       	call   104270 <release>
}
  1021f7:	83 c4 10             	add    $0x10,%esp
  1021fa:	5b                   	pop    %ebx
  1021fb:	5f                   	pop    %edi
  1021fc:	5d                   	pop    %ebp
  1021fd:	c3                   	ret    
  1021fe:	66 90                	xchg   %ax,%ax
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  102200:	ba f7 01 00 00       	mov    $0x1f7,%edx
  102205:	8d 76 00             	lea    0x0(%esi),%esi
  102208:	ec                   	in     (%dx),%al
static int
idewait(int checkerr)
{
  int r;

  while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 
  102209:	0f b6 c0             	movzbl %al,%eax
  10220c:	89 c7                	mov    %eax,%edi
  10220e:	81 e7 c0 00 00 00    	and    $0xc0,%edi
  102214:	83 ff 40             	cmp    $0x40,%edi
  102217:	75 ef                	jne    102208 <ideintr+0x68>
    ;
  if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0)
  102219:	a8 21                	test   $0x21,%al
  10221b:	75 b0                	jne    1021cd <ideintr+0x2d>
}

static inline void
insl(int port, void *addr, int cnt)
{
  asm volatile("cld; rep insl" :
  10221d:	8d 7b 18             	lea    0x18(%ebx),%edi
  102220:	b9 80 00 00 00       	mov    $0x80,%ecx
  102225:	ba f0 01 00 00       	mov    $0x1f0,%edx
  10222a:	fc                   	cld    
  10222b:	f3 6d                	rep insl (%dx),%es:(%edi)
  10222d:	8b 0b                	mov    (%ebx),%ecx
  10222f:	eb 9c                	jmp    1021cd <ideintr+0x2d>
  102231:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  struct buf *b;

  // Take first buffer off queue.
  acquire(&idelock);
  if((b = idequeue) == 0){
    release(&idelock);
  102238:	c7 04 24 80 95 10 00 	movl   $0x109580,(%esp)
  10223f:	e8 2c 20 00 00       	call   104270 <release>
    cprintf("Spurious IDE interrupt.\n");
  102244:	c7 04 24 e5 6d 10 00 	movl   $0x106de5,(%esp)
  10224b:	e8 70 e2 ff ff       	call   1004c0 <cprintf>
    return;
  102250:	eb a5                	jmp    1021f7 <ideintr+0x57>
  102252:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  102259:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00102260 <ideinit>:
  return 0;
}

void
ideinit(void)
{
  102260:	55                   	push   %ebp
  102261:	89 e5                	mov    %esp,%ebp
  102263:	83 ec 18             	sub    $0x18,%esp
  int i;

  initlock(&idelock, "ide");
  102266:	c7 44 24 04 fe 6d 10 	movl   $0x106dfe,0x4(%esp)
  10226d:	00 
  10226e:	c7 04 24 80 95 10 00 	movl   $0x109580,(%esp)
  102275:	e8 b6 1e 00 00       	call   104130 <initlock>
  picenable(IRQ_IDE);
  10227a:	c7 04 24 0e 00 00 00 	movl   $0xe,(%esp)
  102281:	e8 aa 0a 00 00       	call   102d30 <picenable>
  ioapicenable(IRQ_IDE, ncpu - 1);
  102286:	a1 20 ce 10 00       	mov    0x10ce20,%eax
  10228b:	c7 04 24 0e 00 00 00 	movl   $0xe,(%esp)
  102292:	83 e8 01             	sub    $0x1,%eax
  102295:	89 44 24 04          	mov    %eax,0x4(%esp)
  102299:	e8 52 00 00 00       	call   1022f0 <ioapicenable>
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  10229e:	ba f7 01 00 00       	mov    $0x1f7,%edx
  1022a3:	90                   	nop
  1022a4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1022a8:	ec                   	in     (%dx),%al
static int
idewait(int checkerr)
{
  int r;

  while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 
  1022a9:	25 c0 00 00 00       	and    $0xc0,%eax
  1022ae:	83 f8 40             	cmp    $0x40,%eax
  1022b1:	75 f5                	jne    1022a8 <ideinit+0x48>
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  1022b3:	ba f6 01 00 00       	mov    $0x1f6,%edx
  1022b8:	b8 f0 ff ff ff       	mov    $0xfffffff0,%eax
  1022bd:	ee                   	out    %al,(%dx)
  1022be:	31 c9                	xor    %ecx,%ecx
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  1022c0:	b2 f7                	mov    $0xf7,%dl
  1022c2:	eb 0f                	jmp    1022d3 <ideinit+0x73>
  1022c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  ioapicenable(IRQ_IDE, ncpu - 1);
  idewait(0);
  
  // Check if disk 1 is present
  outb(0x1f6, 0xe0 | (1<<4));
  for(i=0; i<1000; i++){
  1022c8:	83 c1 01             	add    $0x1,%ecx
  1022cb:	81 f9 e8 03 00 00    	cmp    $0x3e8,%ecx
  1022d1:	74 0f                	je     1022e2 <ideinit+0x82>
  1022d3:	ec                   	in     (%dx),%al
    if(inb(0x1f7) != 0){
  1022d4:	84 c0                	test   %al,%al
  1022d6:	74 f0                	je     1022c8 <ideinit+0x68>
      havedisk1 = 1;
  1022d8:	c7 05 b8 95 10 00 01 	movl   $0x1,0x1095b8
  1022df:	00 00 00 
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  1022e2:	ba f6 01 00 00       	mov    $0x1f6,%edx
  1022e7:	b8 e0 ff ff ff       	mov    $0xffffffe0,%eax
  1022ec:	ee                   	out    %al,(%dx)
    }
  }
  
  // Switch back to disk 0.
  outb(0x1f6, 0xe0 | (0<<4));
}
  1022ed:	c9                   	leave  
  1022ee:	c3                   	ret    
  1022ef:	90                   	nop

001022f0 <ioapicenable>:
}

void
ioapicenable(int irq, int cpunum)
{
  if(!ismp)
  1022f0:	8b 15 04 c8 10 00    	mov    0x10c804,%edx
  }
}

void
ioapicenable(int irq, int cpunum)
{
  1022f6:	55                   	push   %ebp
  1022f7:	89 e5                	mov    %esp,%ebp
  1022f9:	8b 45 08             	mov    0x8(%ebp),%eax
  if(!ismp)
  1022fc:	85 d2                	test   %edx,%edx
  1022fe:	74 31                	je     102331 <ioapicenable+0x41>
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  102300:	8b 15 b4 c7 10 00    	mov    0x10c7b4,%edx
    return;

  // Mark interrupt edge-triggered, active high,
  // enabled, and routed to the given cpunum,
  // which happens to be that cpu's APIC ID.
  ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
  102306:	8d 48 20             	lea    0x20(%eax),%ecx
  102309:	8d 44 00 10          	lea    0x10(%eax,%eax,1),%eax
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  10230d:	89 02                	mov    %eax,(%edx)
  ioapic->data = data;
  10230f:	8b 15 b4 c7 10 00    	mov    0x10c7b4,%edx
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  102315:	83 c0 01             	add    $0x1,%eax
  ioapic->data = data;
  102318:	89 4a 10             	mov    %ecx,0x10(%edx)
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  10231b:	8b 0d b4 c7 10 00    	mov    0x10c7b4,%ecx

  // Mark interrupt edge-triggered, active high,
  // enabled, and routed to the given cpunum,
  // which happens to be that cpu's APIC ID.
  ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
  ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
  102321:	8b 55 0c             	mov    0xc(%ebp),%edx
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  102324:	89 01                	mov    %eax,(%ecx)
  ioapic->data = data;
  102326:	a1 b4 c7 10 00       	mov    0x10c7b4,%eax

  // Mark interrupt edge-triggered, active high,
  // enabled, and routed to the given cpunum,
  // which happens to be that cpu's APIC ID.
  ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
  ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
  10232b:	c1 e2 18             	shl    $0x18,%edx

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  ioapic->data = data;
  10232e:	89 50 10             	mov    %edx,0x10(%eax)
  // Mark interrupt edge-triggered, active high,
  // enabled, and routed to the given cpunum,
  // which happens to be that cpu's APIC ID.
  ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
  ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
}
  102331:	5d                   	pop    %ebp
  102332:	c3                   	ret    
  102333:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  102339:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00102340 <ioapicinit>:
  ioapic->data = data;
}

void
ioapicinit(void)
{
  102340:	55                   	push   %ebp
  102341:	89 e5                	mov    %esp,%ebp
  102343:	56                   	push   %esi
  102344:	53                   	push   %ebx
  102345:	83 ec 10             	sub    $0x10,%esp
  int i, id, maxintr;

  if(!ismp)
  102348:	8b 0d 04 c8 10 00    	mov    0x10c804,%ecx
  10234e:	85 c9                	test   %ecx,%ecx
  102350:	0f 84 9e 00 00 00    	je     1023f4 <ioapicinit+0xb4>
};

static uint
ioapicread(int reg)
{
  ioapic->reg = reg;
  102356:	c7 05 00 00 c0 fe 01 	movl   $0x1,0xfec00000
  10235d:	00 00 00 
  return ioapic->data;
  102360:	8b 35 10 00 c0 fe    	mov    0xfec00010,%esi
    return;

  ioapic = (volatile struct ioapic*)IOAPIC;
  maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
  id = ioapicread(REG_ID) >> 24;
  if(id != ioapicid)
  102366:	bb 00 00 c0 fe       	mov    $0xfec00000,%ebx
};

static uint
ioapicread(int reg)
{
  ioapic->reg = reg;
  10236b:	c7 05 00 00 c0 fe 00 	movl   $0x0,0xfec00000
  102372:	00 00 00 
  return ioapic->data;
  102375:	a1 10 00 c0 fe       	mov    0xfec00010,%eax
    return;

  ioapic = (volatile struct ioapic*)IOAPIC;
  maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
  id = ioapicread(REG_ID) >> 24;
  if(id != ioapicid)
  10237a:	0f b6 15 00 c8 10 00 	movzbl 0x10c800,%edx
  int i, id, maxintr;

  if(!ismp)
    return;

  ioapic = (volatile struct ioapic*)IOAPIC;
  102381:	c7 05 b4 c7 10 00 00 	movl   $0xfec00000,0x10c7b4
  102388:	00 c0 fe 
  maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
  10238b:	c1 ee 10             	shr    $0x10,%esi
  id = ioapicread(REG_ID) >> 24;
  if(id != ioapicid)
  10238e:	c1 e8 18             	shr    $0x18,%eax

  if(!ismp)
    return;

  ioapic = (volatile struct ioapic*)IOAPIC;
  maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
  102391:	81 e6 ff 00 00 00    	and    $0xff,%esi
  id = ioapicread(REG_ID) >> 24;
  if(id != ioapicid)
  102397:	39 c2                	cmp    %eax,%edx
  102399:	74 12                	je     1023ad <ioapicinit+0x6d>
    cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");
  10239b:	c7 04 24 04 6e 10 00 	movl   $0x106e04,(%esp)
  1023a2:	e8 19 e1 ff ff       	call   1004c0 <cprintf>
  1023a7:	8b 1d b4 c7 10 00    	mov    0x10c7b4,%ebx
  1023ad:	ba 10 00 00 00       	mov    $0x10,%edx
  1023b2:	31 c0                	xor    %eax,%eax
  1023b4:	eb 08                	jmp    1023be <ioapicinit+0x7e>
  1023b6:	66 90                	xchg   %ax,%ax

  // Mark all interrupts edge-triggered, active high, disabled,
  // and not routed to any CPUs.
  for(i = 0; i <= maxintr; i++){
  1023b8:	8b 1d b4 c7 10 00    	mov    0x10c7b4,%ebx
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  1023be:	89 13                	mov    %edx,(%ebx)
  ioapic->data = data;
  1023c0:	8b 1d b4 c7 10 00    	mov    0x10c7b4,%ebx
    cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");

  // Mark all interrupts edge-triggered, active high, disabled,
  // and not routed to any CPUs.
  for(i = 0; i <= maxintr; i++){
    ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i));
  1023c6:	8d 48 20             	lea    0x20(%eax),%ecx
  1023c9:	81 c9 00 00 01 00    	or     $0x10000,%ecx
  if(id != ioapicid)
    cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");

  // Mark all interrupts edge-triggered, active high, disabled,
  // and not routed to any CPUs.
  for(i = 0; i <= maxintr; i++){
  1023cf:	83 c0 01             	add    $0x1,%eax

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  ioapic->data = data;
  1023d2:	89 4b 10             	mov    %ecx,0x10(%ebx)
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  1023d5:	8b 0d b4 c7 10 00    	mov    0x10c7b4,%ecx
  1023db:	8d 5a 01             	lea    0x1(%edx),%ebx
  if(id != ioapicid)
    cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");

  // Mark all interrupts edge-triggered, active high, disabled,
  // and not routed to any CPUs.
  for(i = 0; i <= maxintr; i++){
  1023de:	83 c2 02             	add    $0x2,%edx
  1023e1:	39 c6                	cmp    %eax,%esi
}

static void
ioapicwrite(int reg, uint data)
{
  ioapic->reg = reg;
  1023e3:	89 19                	mov    %ebx,(%ecx)
  ioapic->data = data;
  1023e5:	8b 0d b4 c7 10 00    	mov    0x10c7b4,%ecx
  1023eb:	c7 41 10 00 00 00 00 	movl   $0x0,0x10(%ecx)
  if(id != ioapicid)
    cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");

  // Mark all interrupts edge-triggered, active high, disabled,
  // and not routed to any CPUs.
  for(i = 0; i <= maxintr; i++){
  1023f2:	7d c4                	jge    1023b8 <ioapicinit+0x78>
    ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i));
    ioapicwrite(REG_TABLE+2*i+1, 0);
  }
}
  1023f4:	83 c4 10             	add    $0x10,%esp
  1023f7:	5b                   	pop    %ebx
  1023f8:	5e                   	pop    %esi
  1023f9:	5d                   	pop    %ebp
  1023fa:	c3                   	ret    
  1023fb:	90                   	nop
  1023fc:	90                   	nop
  1023fd:	90                   	nop
  1023fe:	90                   	nop
  1023ff:	90                   	nop

00102400 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
char*
kalloc()
{
  102400:	55                   	push   %ebp
  102401:	89 e5                	mov    %esp,%ebp
  102403:	53                   	push   %ebx
  102404:	83 ec 14             	sub    $0x14,%esp
  struct run *r;

  acquire(&kmem.lock);
  102407:	c7 04 24 c0 c7 10 00 	movl   $0x10c7c0,(%esp)
  10240e:	e8 ad 1e 00 00       	call   1042c0 <acquire>
  r = kmem.freelist;
  102413:	8b 1d f4 c7 10 00    	mov    0x10c7f4,%ebx
  if(r)
  102419:	85 db                	test   %ebx,%ebx
  10241b:	74 07                	je     102424 <kalloc+0x24>
    kmem.freelist = r->next;
  10241d:	8b 03                	mov    (%ebx),%eax
  10241f:	a3 f4 c7 10 00       	mov    %eax,0x10c7f4
  release(&kmem.lock);
  102424:	c7 04 24 c0 c7 10 00 	movl   $0x10c7c0,(%esp)
  10242b:	e8 40 1e 00 00       	call   104270 <release>
  return (char*) r;
}
  102430:	89 d8                	mov    %ebx,%eax
  102432:	83 c4 14             	add    $0x14,%esp
  102435:	5b                   	pop    %ebx
  102436:	5d                   	pop    %ebp
  102437:	c3                   	ret    
  102438:	90                   	nop
  102439:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00102440 <kfree>:
// which normally should have been returned by a
// call to kalloc().  (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(char *v)
{
  102440:	55                   	push   %ebp
  102441:	89 e5                	mov    %esp,%ebp
  102443:	53                   	push   %ebx
  102444:	83 ec 14             	sub    $0x14,%esp
  102447:	8b 5d 08             	mov    0x8(%ebp),%ebx
  struct run *r;

  if(((uint) v) % PGSIZE || (uint)v < 1024*1024 || (uint)v >= PHYSTOP) 
  10244a:	f7 c3 ff 0f 00 00    	test   $0xfff,%ebx
  102450:	75 52                	jne    1024a4 <kfree+0x64>
  102452:	81 fb ff ff 0f 00    	cmp    $0xfffff,%ebx
  102458:	76 4a                	jbe    1024a4 <kfree+0x64>
  10245a:	81 fb ff ff ff 00    	cmp    $0xffffff,%ebx
  102460:	77 42                	ja     1024a4 <kfree+0x64>
    panic("kfree");

  // Fill with junk to catch dangling refs.
  memset(v, 1, PGSIZE);
  102462:	89 1c 24             	mov    %ebx,(%esp)
  102465:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  10246c:	00 
  10246d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  102474:	00 
  102475:	e8 e6 1e 00 00       	call   104360 <memset>

  acquire(&kmem.lock);
  10247a:	c7 04 24 c0 c7 10 00 	movl   $0x10c7c0,(%esp)
  102481:	e8 3a 1e 00 00       	call   1042c0 <acquire>
  r = (struct run *) v;
  r->next = kmem.freelist;
  102486:	a1 f4 c7 10 00       	mov    0x10c7f4,%eax
  10248b:	89 03                	mov    %eax,(%ebx)
  kmem.freelist = r;
  10248d:	89 1d f4 c7 10 00    	mov    %ebx,0x10c7f4
  release(&kmem.lock);
  102493:	c7 45 08 c0 c7 10 00 	movl   $0x10c7c0,0x8(%ebp)
}
  10249a:	83 c4 14             	add    $0x14,%esp
  10249d:	5b                   	pop    %ebx
  10249e:	5d                   	pop    %ebp

  acquire(&kmem.lock);
  r = (struct run *) v;
  r->next = kmem.freelist;
  kmem.freelist = r;
  release(&kmem.lock);
  10249f:	e9 cc 1d 00 00       	jmp    104270 <release>
kfree(char *v)
{
  struct run *r;

  if(((uint) v) % PGSIZE || (uint)v < 1024*1024 || (uint)v >= PHYSTOP) 
    panic("kfree");
  1024a4:	c7 04 24 36 6e 10 00 	movl   $0x106e36,(%esp)
  1024ab:	e8 b0 e5 ff ff       	call   100a60 <panic>

001024b0 <kinit>:
} kmem;

// Initialize free list of physical pages.
void
kinit(void)
{
  1024b0:	55                   	push   %ebp
  1024b1:	89 e5                	mov    %esp,%ebp
  1024b3:	53                   	push   %ebx
  extern char end[];

  initlock(&kmem.lock, "kmem");
  char *p = (char*)PGROUNDUP((uint)end);
  1024b4:	bb c3 0a 11 00       	mov    $0x110ac3,%ebx
} kmem;

// Initialize free list of physical pages.
void
kinit(void)
{
  1024b9:	83 ec 14             	sub    $0x14,%esp
  extern char end[];

  initlock(&kmem.lock, "kmem");
  char *p = (char*)PGROUNDUP((uint)end);
  1024bc:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
void
kinit(void)
{
  extern char end[];

  initlock(&kmem.lock, "kmem");
  1024c2:	c7 44 24 04 3c 6e 10 	movl   $0x106e3c,0x4(%esp)
  1024c9:	00 
  1024ca:	c7 04 24 c0 c7 10 00 	movl   $0x10c7c0,(%esp)
  1024d1:	e8 5a 1c 00 00       	call   104130 <initlock>
  char *p = (char*)PGROUNDUP((uint)end);
  for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
  1024d6:	8d 83 ff 0f 00 00    	lea    0xfff(%ebx),%eax
  1024dc:	3d ff ff ff 00       	cmp    $0xffffff,%eax
  1024e1:	77 20                	ja     102503 <kinit+0x53>
  1024e3:	90                   	nop
  1024e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    kfree(p);
  1024e8:	89 1c 24             	mov    %ebx,(%esp)
{
  extern char end[];

  initlock(&kmem.lock, "kmem");
  char *p = (char*)PGROUNDUP((uint)end);
  for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
  1024eb:	81 c3 00 10 00 00    	add    $0x1000,%ebx
    kfree(p);
  1024f1:	e8 4a ff ff ff       	call   102440 <kfree>
{
  extern char end[];

  initlock(&kmem.lock, "kmem");
  char *p = (char*)PGROUNDUP((uint)end);
  for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
  1024f6:	8d 83 ff 0f 00 00    	lea    0xfff(%ebx),%eax
  1024fc:	3d ff ff ff 00       	cmp    $0xffffff,%eax
  102501:	76 e5                	jbe    1024e8 <kinit+0x38>
    kfree(p);
}
  102503:	83 c4 14             	add    $0x14,%esp
  102506:	5b                   	pop    %ebx
  102507:	5d                   	pop    %ebp
  102508:	c3                   	ret    
  102509:	90                   	nop
  10250a:	90                   	nop
  10250b:	90                   	nop
  10250c:	90                   	nop
  10250d:	90                   	nop
  10250e:	90                   	nop
  10250f:	90                   	nop

00102510 <kbdgetc>:
#include "defs.h"
#include "kbd.h"

int
kbdgetc(void)
{
  102510:	55                   	push   %ebp
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  102511:	ba 64 00 00 00       	mov    $0x64,%edx
  102516:	89 e5                	mov    %esp,%ebp
  102518:	ec                   	in     (%dx),%al
  102519:	89 c2                	mov    %eax,%edx
    normalmap, shiftmap, ctlmap, ctlmap
  };
  uint st, data, c;

  st = inb(KBSTATP);
  if((st & KBS_DIB) == 0)
  10251b:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  102520:	83 e2 01             	and    $0x1,%edx
  102523:	74 3e                	je     102563 <kbdgetc+0x53>
  102525:	ba 60 00 00 00       	mov    $0x60,%edx
  10252a:	ec                   	in     (%dx),%al
    return -1;
  data = inb(KBDATAP);
  10252b:	0f b6 c0             	movzbl %al,%eax

  if(data == 0xE0){
  10252e:	3d e0 00 00 00       	cmp    $0xe0,%eax
  102533:	0f 84 7f 00 00 00    	je     1025b8 <kbdgetc+0xa8>
    shift |= E0ESC;
    return 0;
  } else if(data & 0x80){
  102539:	84 c0                	test   %al,%al
  10253b:	79 2b                	jns    102568 <kbdgetc+0x58>
    // Key released
    data = (shift & E0ESC ? data : data & 0x7F);
  10253d:	8b 15 bc 95 10 00    	mov    0x1095bc,%edx
  102543:	f6 c2 40             	test   $0x40,%dl
  102546:	75 03                	jne    10254b <kbdgetc+0x3b>
  102548:	83 e0 7f             	and    $0x7f,%eax
    shift &= ~(shiftcode[data] | E0ESC);
  10254b:	0f b6 80 60 6e 10 00 	movzbl 0x106e60(%eax),%eax
  102552:	83 c8 40             	or     $0x40,%eax
  102555:	0f b6 c0             	movzbl %al,%eax
  102558:	f7 d0                	not    %eax
  10255a:	21 d0                	and    %edx,%eax
  10255c:	a3 bc 95 10 00       	mov    %eax,0x1095bc
  102561:	31 c0                	xor    %eax,%eax
      c += 'A' - 'a';
    else if('A' <= c && c <= 'Z')
      c += 'a' - 'A';
  }
  return c;
}
  102563:	5d                   	pop    %ebp
  102564:	c3                   	ret    
  102565:	8d 76 00             	lea    0x0(%esi),%esi
  } else if(data & 0x80){
    // Key released
    data = (shift & E0ESC ? data : data & 0x7F);
    shift &= ~(shiftcode[data] | E0ESC);
    return 0;
  } else if(shift & E0ESC){
  102568:	8b 0d bc 95 10 00    	mov    0x1095bc,%ecx
  10256e:	f6 c1 40             	test   $0x40,%cl
  102571:	74 05                	je     102578 <kbdgetc+0x68>
    // Last character was an E0 escape; or with 0x80
    data |= 0x80;
  102573:	0c 80                	or     $0x80,%al
    shift &= ~E0ESC;
  102575:	83 e1 bf             	and    $0xffffffbf,%ecx
  }

  shift |= shiftcode[data];
  shift ^= togglecode[data];
  102578:	0f b6 90 60 6e 10 00 	movzbl 0x106e60(%eax),%edx
  10257f:	09 ca                	or     %ecx,%edx
  102581:	0f b6 88 60 6f 10 00 	movzbl 0x106f60(%eax),%ecx
  102588:	31 ca                	xor    %ecx,%edx
  c = charcode[shift & (CTL | SHIFT)][data];
  10258a:	89 d1                	mov    %edx,%ecx
  10258c:	83 e1 03             	and    $0x3,%ecx
  10258f:	8b 0c 8d 60 70 10 00 	mov    0x107060(,%ecx,4),%ecx
    data |= 0x80;
    shift &= ~E0ESC;
  }

  shift |= shiftcode[data];
  shift ^= togglecode[data];
  102596:	89 15 bc 95 10 00    	mov    %edx,0x1095bc
  c = charcode[shift & (CTL | SHIFT)][data];
  if(shift & CAPSLOCK){
  10259c:	83 e2 08             	and    $0x8,%edx
    shift &= ~E0ESC;
  }

  shift |= shiftcode[data];
  shift ^= togglecode[data];
  c = charcode[shift & (CTL | SHIFT)][data];
  10259f:	0f b6 04 01          	movzbl (%ecx,%eax,1),%eax
  if(shift & CAPSLOCK){
  1025a3:	74 be                	je     102563 <kbdgetc+0x53>
    if('a' <= c && c <= 'z')
  1025a5:	8d 50 9f             	lea    -0x61(%eax),%edx
  1025a8:	83 fa 19             	cmp    $0x19,%edx
  1025ab:	77 1b                	ja     1025c8 <kbdgetc+0xb8>
      c += 'A' - 'a';
  1025ad:	83 e8 20             	sub    $0x20,%eax
    else if('A' <= c && c <= 'Z')
      c += 'a' - 'A';
  }
  return c;
}
  1025b0:	5d                   	pop    %ebp
  1025b1:	c3                   	ret    
  1025b2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  if((st & KBS_DIB) == 0)
    return -1;
  data = inb(KBDATAP);

  if(data == 0xE0){
    shift |= E0ESC;
  1025b8:	30 c0                	xor    %al,%al
  1025ba:	83 0d bc 95 10 00 40 	orl    $0x40,0x1095bc
      c += 'A' - 'a';
    else if('A' <= c && c <= 'Z')
      c += 'a' - 'A';
  }
  return c;
}
  1025c1:	5d                   	pop    %ebp
  1025c2:	c3                   	ret    
  1025c3:	90                   	nop
  1025c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  shift ^= togglecode[data];
  c = charcode[shift & (CTL | SHIFT)][data];
  if(shift & CAPSLOCK){
    if('a' <= c && c <= 'z')
      c += 'A' - 'a';
    else if('A' <= c && c <= 'Z')
  1025c8:	8d 50 bf             	lea    -0x41(%eax),%edx
  1025cb:	83 fa 19             	cmp    $0x19,%edx
  1025ce:	77 93                	ja     102563 <kbdgetc+0x53>
      c += 'a' - 'A';
  1025d0:	83 c0 20             	add    $0x20,%eax
  }
  return c;
}
  1025d3:	5d                   	pop    %ebp
  1025d4:	c3                   	ret    
  1025d5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1025d9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001025e0 <kbdintr>:

void
kbdintr(void)
{
  1025e0:	55                   	push   %ebp
  1025e1:	89 e5                	mov    %esp,%ebp
  1025e3:	83 ec 18             	sub    $0x18,%esp
  consoleintr(kbdgetc);
  1025e6:	c7 04 24 10 25 10 00 	movl   $0x102510,(%esp)
  1025ed:	e8 2e e1 ff ff       	call   100720 <consoleintr>
}
  1025f2:	c9                   	leave  
  1025f3:	c3                   	ret    
  1025f4:	90                   	nop
  1025f5:	90                   	nop
  1025f6:	90                   	nop
  1025f7:	90                   	nop
  1025f8:	90                   	nop
  1025f9:	90                   	nop
  1025fa:	90                   	nop
  1025fb:	90                   	nop
  1025fc:	90                   	nop
  1025fd:	90                   	nop
  1025fe:	90                   	nop
  1025ff:	90                   	nop

00102600 <lapiceoi>:

// Acknowledge interrupt.
void
lapiceoi(void)
{
  if(lapic)
  102600:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
}

// Acknowledge interrupt.
void
lapiceoi(void)
{
  102605:	55                   	push   %ebp
  102606:	89 e5                	mov    %esp,%ebp
  if(lapic)
  102608:	85 c0                	test   %eax,%eax
  10260a:	74 12                	je     10261e <lapiceoi+0x1e>
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  10260c:	c7 80 b0 00 00 00 00 	movl   $0x0,0xb0(%eax)
  102613:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  102616:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10261b:	8b 40 20             	mov    0x20(%eax),%eax
void
lapiceoi(void)
{
  if(lapic)
    lapicw(EOI, 0);
}
  10261e:	5d                   	pop    %ebp
  10261f:	c3                   	ret    

00102620 <microdelay>:

// Spin for a given number of microseconds.
// On real hardware would want to tune this dynamically.
void
microdelay(int us)
{
  102620:	55                   	push   %ebp
  102621:	89 e5                	mov    %esp,%ebp
}
  102623:	5d                   	pop    %ebp
  102624:	c3                   	ret    
  102625:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  102629:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00102630 <lapicstartap>:

// Start additional processor running bootstrap code at addr.
// See Appendix B of MultiProcessor Specification.
void
lapicstartap(uchar apicid, uint addr)
{
  102630:	55                   	push   %ebp
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  102631:	ba 70 00 00 00       	mov    $0x70,%edx
  102636:	89 e5                	mov    %esp,%ebp
  102638:	b8 0f 00 00 00       	mov    $0xf,%eax
  10263d:	53                   	push   %ebx
  10263e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  102641:	0f b6 5d 08          	movzbl 0x8(%ebp),%ebx
  102645:	ee                   	out    %al,(%dx)
  102646:	b8 0a 00 00 00       	mov    $0xa,%eax
  10264b:	b2 71                	mov    $0x71,%dl
  10264d:	ee                   	out    %al,(%dx)
  // the AP startup code prior to the [universal startup algorithm]."
  outb(IO_RTC, 0xF);  // offset 0xF is shutdown code
  outb(IO_RTC+1, 0x0A);
  wrv = (ushort*)(0x40<<4 | 0x67);  // Warm reset vector
  wrv[0] = 0;
  wrv[1] = addr >> 4;
  10264e:	89 c8                	mov    %ecx,%eax
  102650:	c1 e8 04             	shr    $0x4,%eax
  102653:	66 a3 69 04 00 00    	mov    %ax,0x469
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102659:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10265e:	c1 e3 18             	shl    $0x18,%ebx
  // and the warm reset vector (DWORD based at 40:67) to point at
  // the AP startup code prior to the [universal startup algorithm]."
  outb(IO_RTC, 0xF);  // offset 0xF is shutdown code
  outb(IO_RTC+1, 0x0A);
  wrv = (ushort*)(0x40<<4 | 0x67);  // Warm reset vector
  wrv[0] = 0;
  102661:	66 c7 05 67 04 00 00 	movw   $0x0,0x467
  102668:	00 00 

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  lapic[ID];  // wait for write to finish, by reading
  10266a:	c1 e9 0c             	shr    $0xc,%ecx
  10266d:	80 cd 06             	or     $0x6,%ch
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102670:	89 98 10 03 00 00    	mov    %ebx,0x310(%eax)
  lapic[ID];  // wait for write to finish, by reading
  102676:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10267b:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  10267e:	c7 80 00 03 00 00 00 	movl   $0xc500,0x300(%eax)
  102685:	c5 00 00 
  lapic[ID];  // wait for write to finish, by reading
  102688:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10268d:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102690:	c7 80 00 03 00 00 00 	movl   $0x8500,0x300(%eax)
  102697:	85 00 00 
  lapic[ID];  // wait for write to finish, by reading
  10269a:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10269f:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1026a2:	89 98 10 03 00 00    	mov    %ebx,0x310(%eax)
  lapic[ID];  // wait for write to finish, by reading
  1026a8:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1026ad:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1026b0:	89 88 00 03 00 00    	mov    %ecx,0x300(%eax)
  lapic[ID];  // wait for write to finish, by reading
  1026b6:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1026bb:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1026be:	89 98 10 03 00 00    	mov    %ebx,0x310(%eax)
  lapic[ID];  // wait for write to finish, by reading
  1026c4:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1026c9:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1026cc:	89 88 00 03 00 00    	mov    %ecx,0x300(%eax)
  lapic[ID];  // wait for write to finish, by reading
  1026d2:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  for(i = 0; i < 2; i++){
    lapicw(ICRHI, apicid<<24);
    lapicw(ICRLO, STARTUP | (addr>>12));
    microdelay(200);
  }
}
  1026d7:	5b                   	pop    %ebx
  1026d8:	5d                   	pop    %ebp

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  lapic[ID];  // wait for write to finish, by reading
  1026d9:	8b 40 20             	mov    0x20(%eax),%eax
  for(i = 0; i < 2; i++){
    lapicw(ICRHI, apicid<<24);
    lapicw(ICRLO, STARTUP | (addr>>12));
    microdelay(200);
  }
}
  1026dc:	c3                   	ret    
  1026dd:	8d 76 00             	lea    0x0(%esi),%esi

001026e0 <cpunum>:
  lapicw(TPR, 0);
}

int
cpunum(void)
{
  1026e0:	55                   	push   %ebp
  1026e1:	89 e5                	mov    %esp,%ebp
  1026e3:	83 ec 18             	sub    $0x18,%esp

static inline uint
readeflags(void)
{
  uint eflags;
  asm volatile("pushfl; popl %0" : "=r" (eflags));
  1026e6:	9c                   	pushf  
  1026e7:	58                   	pop    %eax
  // Cannot call cpu when interrupts are enabled:
  // result not guaranteed to last long enough to be used!
  // Would prefer to panic but even printing is chancy here:
  // almost everything, including cprintf and panic, calls cpu,
  // often indirectly through acquire and release.
  if(readeflags()&FL_IF){
  1026e8:	f6 c4 02             	test   $0x2,%ah
  1026eb:	74 12                	je     1026ff <cpunum+0x1f>
    static int n;
    if(n++ == 0)
  1026ed:	a1 c0 95 10 00       	mov    0x1095c0,%eax
  1026f2:	8d 50 01             	lea    0x1(%eax),%edx
  1026f5:	85 c0                	test   %eax,%eax
  1026f7:	89 15 c0 95 10 00    	mov    %edx,0x1095c0
  1026fd:	74 19                	je     102718 <cpunum+0x38>
      cprintf("cpu called from %x with interrupts enabled\n",
        __builtin_return_address(0));
  }

  if(lapic)
  1026ff:	8b 15 f8 c7 10 00    	mov    0x10c7f8,%edx
  102705:	31 c0                	xor    %eax,%eax
  102707:	85 d2                	test   %edx,%edx
  102709:	74 06                	je     102711 <cpunum+0x31>
    return lapic[ID]>>24;
  10270b:	8b 42 20             	mov    0x20(%edx),%eax
  10270e:	c1 e8 18             	shr    $0x18,%eax
  return 0;
}
  102711:	c9                   	leave  
  102712:	c3                   	ret    
  102713:	90                   	nop
  102714:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  // almost everything, including cprintf and panic, calls cpu,
  // often indirectly through acquire and release.
  if(readeflags()&FL_IF){
    static int n;
    if(n++ == 0)
      cprintf("cpu called from %x with interrupts enabled\n",
  102718:	8b 45 04             	mov    0x4(%ebp),%eax
  10271b:	c7 04 24 70 70 10 00 	movl   $0x107070,(%esp)
  102722:	89 44 24 04          	mov    %eax,0x4(%esp)
  102726:	e8 95 dd ff ff       	call   1004c0 <cprintf>
  10272b:	eb d2                	jmp    1026ff <cpunum+0x1f>
  10272d:	8d 76 00             	lea    0x0(%esi),%esi

00102730 <lapicinit>:
  lapic[ID];  // wait for write to finish, by reading
}

void
lapicinit(int c)
{
  102730:	55                   	push   %ebp
  102731:	89 e5                	mov    %esp,%ebp
  102733:	83 ec 18             	sub    $0x18,%esp
  cprintf("lapicinit: %d 0x%x\n", c, lapic);
  102736:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10273b:	c7 04 24 9c 70 10 00 	movl   $0x10709c,(%esp)
  102742:	89 44 24 08          	mov    %eax,0x8(%esp)
  102746:	8b 45 08             	mov    0x8(%ebp),%eax
  102749:	89 44 24 04          	mov    %eax,0x4(%esp)
  10274d:	e8 6e dd ff ff       	call   1004c0 <cprintf>
  if(!lapic) 
  102752:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  102757:	85 c0                	test   %eax,%eax
  102759:	0f 84 0a 01 00 00    	je     102869 <lapicinit+0x139>
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  10275f:	c7 80 f0 00 00 00 3f 	movl   $0x13f,0xf0(%eax)
  102766:	01 00 00 
  lapic[ID];  // wait for write to finish, by reading
  102769:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10276e:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102771:	c7 80 e0 03 00 00 0b 	movl   $0xb,0x3e0(%eax)
  102778:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  10277b:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  102780:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102783:	c7 80 20 03 00 00 20 	movl   $0x20020,0x320(%eax)
  10278a:	00 02 00 
  lapic[ID];  // wait for write to finish, by reading
  10278d:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  102792:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102795:	c7 80 80 03 00 00 80 	movl   $0x989680,0x380(%eax)
  10279c:	96 98 00 
  lapic[ID];  // wait for write to finish, by reading
  10279f:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1027a4:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1027a7:	c7 80 50 03 00 00 00 	movl   $0x10000,0x350(%eax)
  1027ae:	00 01 00 
  lapic[ID];  // wait for write to finish, by reading
  1027b1:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1027b6:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1027b9:	c7 80 60 03 00 00 00 	movl   $0x10000,0x360(%eax)
  1027c0:	00 01 00 
  lapic[ID];  // wait for write to finish, by reading
  1027c3:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1027c8:	8b 50 20             	mov    0x20(%eax),%edx
  lapicw(LINT0, MASKED);
  lapicw(LINT1, MASKED);

  // Disable performance counter overflow interrupts
  // on machines that provide that interrupt entry.
  if(((lapic[VER]>>16) & 0xFF) >= 4)
  1027cb:	8b 50 30             	mov    0x30(%eax),%edx
  1027ce:	c1 ea 10             	shr    $0x10,%edx
  1027d1:	80 fa 03             	cmp    $0x3,%dl
  1027d4:	0f 87 96 00 00 00    	ja     102870 <lapicinit+0x140>
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1027da:	c7 80 70 03 00 00 33 	movl   $0x33,0x370(%eax)
  1027e1:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  1027e4:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1027e9:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1027ec:	c7 80 80 02 00 00 00 	movl   $0x0,0x280(%eax)
  1027f3:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  1027f6:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  1027fb:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  1027fe:	c7 80 80 02 00 00 00 	movl   $0x0,0x280(%eax)
  102805:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  102808:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10280d:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102810:	c7 80 b0 00 00 00 00 	movl   $0x0,0xb0(%eax)
  102817:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  10281a:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10281f:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102822:	c7 80 10 03 00 00 00 	movl   $0x0,0x310(%eax)
  102829:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  10282c:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  102831:	8b 50 20             	mov    0x20(%eax),%edx
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102834:	c7 80 00 03 00 00 00 	movl   $0x88500,0x300(%eax)
  10283b:	85 08 00 
  lapic[ID];  // wait for write to finish, by reading
  10283e:	8b 0d f8 c7 10 00    	mov    0x10c7f8,%ecx
  102844:	8b 41 20             	mov    0x20(%ecx),%eax
  102847:	8d 91 00 03 00 00    	lea    0x300(%ecx),%edx
  10284d:	8d 76 00             	lea    0x0(%esi),%esi
  lapicw(EOI, 0);

  // Send an Init Level De-Assert to synchronise arbitration ID's.
  lapicw(ICRHI, 0);
  lapicw(ICRLO, BCAST | INIT | LEVEL);
  while(lapic[ICRLO] & DELIVS)
  102850:	8b 02                	mov    (%edx),%eax
  102852:	f6 c4 10             	test   $0x10,%ah
  102855:	75 f9                	jne    102850 <lapicinit+0x120>
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102857:	c7 81 80 00 00 00 00 	movl   $0x0,0x80(%ecx)
  10285e:	00 00 00 
  lapic[ID];  // wait for write to finish, by reading
  102861:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  102866:	8b 40 20             	mov    0x20(%eax),%eax
  while(lapic[ICRLO] & DELIVS)
    ;

  // Enable interrupts on the APIC (but not on the processor).
  lapicw(TPR, 0);
}
  102869:	c9                   	leave  
  10286a:	c3                   	ret    
  10286b:	90                   	nop
  10286c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
volatile uint *lapic;  // Initialized in mp.c

static void
lapicw(int index, int value)
{
  lapic[index] = value;
  102870:	c7 80 40 03 00 00 00 	movl   $0x10000,0x340(%eax)
  102877:	00 01 00 
  lapic[ID];  // wait for write to finish, by reading
  10287a:	a1 f8 c7 10 00       	mov    0x10c7f8,%eax
  10287f:	8b 50 20             	mov    0x20(%eax),%edx
  102882:	e9 53 ff ff ff       	jmp    1027da <lapicinit+0xaa>
  102887:	90                   	nop
  102888:	90                   	nop
  102889:	90                   	nop
  10288a:	90                   	nop
  10288b:	90                   	nop
  10288c:	90                   	nop
  10288d:	90                   	nop
  10288e:	90                   	nop
  10288f:	90                   	nop

00102890 <mpmain>:
// Common CPU setup code.
// Bootstrap CPU comes here from mainc().
// Other CPUs jump here from bootother.S.
static void
mpmain(void)
{
  102890:	55                   	push   %ebp
  102891:	89 e5                	mov    %esp,%ebp
  102893:	53                   	push   %ebx
  102894:	83 ec 14             	sub    $0x14,%esp
  if(cpunum() != mpbcpu()) {
  102897:	e8 44 fe ff ff       	call   1026e0 <cpunum>
  10289c:	89 c3                	mov    %eax,%ebx
  10289e:	e8 ed 01 00 00       	call   102a90 <mpbcpu>
  1028a3:	39 c3                	cmp    %eax,%ebx
  1028a5:	74 16                	je     1028bd <mpmain+0x2d>
    ksegment();
  1028a7:	e8 84 42 00 00       	call   106b30 <ksegment>
  1028ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    lapicinit(cpunum());
  1028b0:	e8 2b fe ff ff       	call   1026e0 <cpunum>
  1028b5:	89 04 24             	mov    %eax,(%esp)
  1028b8:	e8 73 fe ff ff       	call   102730 <lapicinit>
  }
  vmenable();        // turn on paging
  1028bd:	e8 6e 3b 00 00       	call   106430 <vmenable>
  cprintf("cpu%d: starting\n", cpu->id);
  1028c2:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  1028c8:	0f b6 00             	movzbl (%eax),%eax
  1028cb:	c7 04 24 b0 70 10 00 	movl   $0x1070b0,(%esp)
  1028d2:	89 44 24 04          	mov    %eax,0x4(%esp)
  1028d6:	e8 e5 db ff ff       	call   1004c0 <cprintf>
  idtinit();       // load idt register
  1028db:	e8 40 2c 00 00       	call   105520 <idtinit>
  xchg(&cpu->booted, 1);
  1028e0:	65 8b 15 00 00 00 00 	mov    %gs:0x0,%edx
xchg(volatile uint *addr, uint newval)
{
  uint result;
  
  // The + in "+m" denotes a read-modify-write operand.
  asm volatile("lock; xchgl %0, %1" :
  1028e7:	b8 01 00 00 00       	mov    $0x1,%eax
  1028ec:	f0 87 82 a8 00 00 00 	lock xchg %eax,0xa8(%edx)
  scheduler();     // start running processes
  1028f3:	e8 a8 0d 00 00       	call   1036a0 <scheduler>
  1028f8:	90                   	nop
  1028f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00102900 <mainc>:
  panic("jkstack");
}

void
mainc(void)
{
  102900:	55                   	push   %ebp
  102901:	89 e5                	mov    %esp,%ebp
  102903:	53                   	push   %ebx
  102904:	83 ec 14             	sub    $0x14,%esp
  cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
  102907:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  10290d:	0f b6 00             	movzbl (%eax),%eax
  102910:	c7 04 24 c1 70 10 00 	movl   $0x1070c1,(%esp)
  102917:	89 44 24 04          	mov    %eax,0x4(%esp)
  10291b:	e8 a0 db ff ff       	call   1004c0 <cprintf>
  kvmalloc();      // initialize the kernel page table
  102920:	e8 cb 3d 00 00       	call   1066f0 <kvmalloc>
  pinit();         // process table
  102925:	e8 e6 17 00 00       	call   104110 <pinit>
  tvinit();        // trap vectors
  10292a:	e8 a1 2e 00 00       	call   1057d0 <tvinit>
  10292f:	90                   	nop
  binit();         // buffer cache
  102930:	e8 4b d8 ff ff       	call   100180 <binit>
  fileinit();      // file table
  102935:	e8 b6 e8 ff ff       	call   1011f0 <fileinit>
  iinit();         // inode cache
  10293a:	e8 c1 f6 ff ff       	call   102000 <iinit>
  10293f:	90                   	nop
  ideinit();       // disk
  102940:	e8 1b f9 ff ff       	call   102260 <ideinit>
  if(!ismp)
  102945:	a1 04 c8 10 00       	mov    0x10c804,%eax
  10294a:	85 c0                	test   %eax,%eax
  10294c:	0f 84 ac 00 00 00    	je     1029fe <mainc+0xfe>
    timerinit();   // uniprocessor timer
  userinit();      // first user process
  102952:	e8 f9 15 00 00       	call   103f50 <userinit>
  char *stack;

  // Write bootstrap code to unused memory at 0x7000.  The linker has
  // placed the start of bootother.S there.
  code = (uchar *) 0x7000;
  memmove(code, _binary_bootother_start, (uint)_binary_bootother_size);
  102957:	c7 44 24 08 6a 00 00 	movl   $0x6a,0x8(%esp)
  10295e:	00 
  10295f:	c7 44 24 04 b4 8c 10 	movl   $0x108cb4,0x4(%esp)
  102966:	00 
  102967:	c7 04 24 00 70 00 00 	movl   $0x7000,(%esp)
  10296e:	e8 6d 1a 00 00       	call   1043e0 <memmove>

  for(c = cpus; c < cpus+ncpu; c++){
  102973:	a1 20 ce 10 00       	mov    0x10ce20,%eax
  102978:	8d 04 40             	lea    (%eax,%eax,2),%eax
  10297b:	c1 e0 06             	shl    $0x6,%eax
  10297e:	05 20 c8 10 00       	add    $0x10c820,%eax
  102983:	3d 20 c8 10 00       	cmp    $0x10c820,%eax
  102988:	76 6a                	jbe    1029f4 <mainc+0xf4>
  10298a:	bb 20 c8 10 00       	mov    $0x10c820,%ebx
  10298f:	90                   	nop
    if(c == cpus+cpunum())  // We've started already.
  102990:	e8 4b fd ff ff       	call   1026e0 <cpunum>
  102995:	8d 04 40             	lea    (%eax,%eax,2),%eax
  102998:	c1 e0 06             	shl    $0x6,%eax
  10299b:	05 20 c8 10 00       	add    $0x10c820,%eax
  1029a0:	39 c3                	cmp    %eax,%ebx
  1029a2:	74 36                	je     1029da <mainc+0xda>
      continue;

    // Fill in %esp, %eip and start code on cpu.
    stack = kalloc();
  1029a4:	e8 57 fa ff ff       	call   102400 <kalloc>
    *(void**)(code-4) = stack + KSTACKSIZE;
    *(void**)(code-8) = mpmain;
  1029a9:	c7 05 f8 6f 00 00 90 	movl   $0x102890,0x6ff8
  1029b0:	28 10 00 
    if(c == cpus+cpunum())  // We've started already.
      continue;

    // Fill in %esp, %eip and start code on cpu.
    stack = kalloc();
    *(void**)(code-4) = stack + KSTACKSIZE;
  1029b3:	05 00 10 00 00       	add    $0x1000,%eax
  1029b8:	a3 fc 6f 00 00       	mov    %eax,0x6ffc
    *(void**)(code-8) = mpmain;
    lapicstartap(c->id, (uint)code);
  1029bd:	c7 44 24 04 00 70 00 	movl   $0x7000,0x4(%esp)
  1029c4:	00 
  1029c5:	0f b6 03             	movzbl (%ebx),%eax
  1029c8:	89 04 24             	mov    %eax,(%esp)
  1029cb:	e8 60 fc ff ff       	call   102630 <lapicstartap>

    // Wait for cpu to finish mpmain()
    while(c->booted == 0)
  1029d0:	8b 83 a8 00 00 00    	mov    0xa8(%ebx),%eax
  1029d6:	85 c0                	test   %eax,%eax
  1029d8:	74 f6                	je     1029d0 <mainc+0xd0>
  // Write bootstrap code to unused memory at 0x7000.  The linker has
  // placed the start of bootother.S there.
  code = (uchar *) 0x7000;
  memmove(code, _binary_bootother_start, (uint)_binary_bootother_size);

  for(c = cpus; c < cpus+ncpu; c++){
  1029da:	a1 20 ce 10 00       	mov    0x10ce20,%eax
  1029df:	81 c3 c0 00 00 00    	add    $0xc0,%ebx
  1029e5:	8d 04 40             	lea    (%eax,%eax,2),%eax
  1029e8:	c1 e0 06             	shl    $0x6,%eax
  1029eb:	05 20 c8 10 00       	add    $0x10c820,%eax
  1029f0:	39 c3                	cmp    %eax,%ebx
  1029f2:	72 9c                	jb     102990 <mainc+0x90>
  userinit();      // first user process
  bootothers();    // start other processors

  // Finish setting up this processor in mpmain.
  mpmain();
}
  1029f4:	83 c4 14             	add    $0x14,%esp
  1029f7:	5b                   	pop    %ebx
  1029f8:	5d                   	pop    %ebp
    timerinit();   // uniprocessor timer
  userinit();      // first user process
  bootothers();    // start other processors

  // Finish setting up this processor in mpmain.
  mpmain();
  1029f9:	e9 92 fe ff ff       	jmp    102890 <mpmain>
  binit();         // buffer cache
  fileinit();      // file table
  iinit();         // inode cache
  ideinit();       // disk
  if(!ismp)
    timerinit();   // uniprocessor timer
  1029fe:	e8 bd 2a 00 00       	call   1054c0 <timerinit>
  102a03:	e9 4a ff ff ff       	jmp    102952 <mainc+0x52>
  102a08:	90                   	nop
  102a09:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00102a10 <jkstack>:
  jkstack();       // call mainc() on a properly-allocated stack 
}

void
jkstack(void)
{
  102a10:	55                   	push   %ebp
  102a11:	89 e5                	mov    %esp,%ebp
  102a13:	83 ec 18             	sub    $0x18,%esp
  char *kstack = kalloc();
  102a16:	e8 e5 f9 ff ff       	call   102400 <kalloc>
  if(!kstack)
  102a1b:	85 c0                	test   %eax,%eax
  102a1d:	74 19                	je     102a38 <jkstack+0x28>
    panic("jkstack\n");
  char *top = kstack + PGSIZE;
  asm volatile("movl %0,%%esp" : : "r" (top));
  102a1f:	05 00 10 00 00       	add    $0x1000,%eax
  102a24:	89 c4                	mov    %eax,%esp
  asm volatile("call mainc");
  102a26:	e8 d5 fe ff ff       	call   102900 <mainc>
  panic("jkstack");
  102a2b:	c7 04 24 e1 70 10 00 	movl   $0x1070e1,(%esp)
  102a32:	e8 29 e0 ff ff       	call   100a60 <panic>
  102a37:	90                   	nop
void
jkstack(void)
{
  char *kstack = kalloc();
  if(!kstack)
    panic("jkstack\n");
  102a38:	c7 04 24 d8 70 10 00 	movl   $0x1070d8,(%esp)
  102a3f:	e8 1c e0 ff ff       	call   100a60 <panic>
  102a44:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  102a4a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00102a50 <main>:
void mainc(void);

// Bootstrap processor starts running C code here.
int
main(void)
{
  102a50:	55                   	push   %ebp
  102a51:	89 e5                	mov    %esp,%ebp
  102a53:	83 e4 f0             	and    $0xfffffff0,%esp
  102a56:	83 ec 10             	sub    $0x10,%esp
  mpinit();        // collect info about this machine
  102a59:	e8 d2 00 00 00       	call   102b30 <mpinit>
  lapicinit(mpbcpu());
  102a5e:	e8 2d 00 00 00       	call   102a90 <mpbcpu>
  102a63:	89 04 24             	mov    %eax,(%esp)
  102a66:	e8 c5 fc ff ff       	call   102730 <lapicinit>
  ksegment();      // set up segments
  102a6b:	e8 c0 40 00 00       	call   106b30 <ksegment>
  picinit();       // interrupt controller
  102a70:	e8 eb 02 00 00       	call   102d60 <picinit>
  ioapicinit();    // another interrupt controller
  102a75:	e8 c6 f8 ff ff       	call   102340 <ioapicinit>
  consoleinit();   // I/O devices & their interrupts
  102a7a:	e8 71 d7 ff ff       	call   1001f0 <consoleinit>
  102a7f:	90                   	nop
  uartinit();      // serial port
  102a80:	e8 7b 2e 00 00       	call   105900 <uartinit>
  kinit();         // initialize memory allocator
  102a85:	e8 26 fa ff ff       	call   1024b0 <kinit>
  jkstack();       // call mainc() on a properly-allocated stack 
  102a8a:	e8 81 ff ff ff       	call   102a10 <jkstack>
  102a8f:	90                   	nop

00102a90 <mpbcpu>:
int ncpu;
uchar ioapicid;

int
mpbcpu(void)
{
  102a90:	a1 c4 95 10 00       	mov    0x1095c4,%eax
  102a95:	55                   	push   %ebp
  102a96:	89 e5                	mov    %esp,%ebp
  return bcpu-cpus;
}
  102a98:	5d                   	pop    %ebp
int ncpu;
uchar ioapicid;

int
mpbcpu(void)
{
  102a99:	2d 20 c8 10 00       	sub    $0x10c820,%eax
  102a9e:	c1 f8 06             	sar    $0x6,%eax
  102aa1:	69 c0 ab aa aa aa    	imul   $0xaaaaaaab,%eax,%eax
  return bcpu-cpus;
}
  102aa7:	c3                   	ret    
  102aa8:	90                   	nop
  102aa9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00102ab0 <mpsearch1>:
}

// Look for an MP structure in the len bytes at addr.
static struct mp*
mpsearch1(uchar *addr, int len)
{
  102ab0:	55                   	push   %ebp
  102ab1:	89 e5                	mov    %esp,%ebp
  102ab3:	56                   	push   %esi
  102ab4:	89 d6                	mov    %edx,%esi
  102ab6:	53                   	push   %ebx
  102ab7:	89 c3                	mov    %eax,%ebx
  102ab9:	83 ec 10             	sub    $0x10,%esp
  uchar *e, *p;

  cprintf("mpsearch1 0x%x %d\n", addr, len);
  e = addr+len;
  102abc:	8d 34 33             	lea    (%ebx,%esi,1),%esi
static struct mp*
mpsearch1(uchar *addr, int len)
{
  uchar *e, *p;

  cprintf("mpsearch1 0x%x %d\n", addr, len);
  102abf:	89 54 24 08          	mov    %edx,0x8(%esp)
  102ac3:	89 44 24 04          	mov    %eax,0x4(%esp)
  102ac7:	c7 04 24 e9 70 10 00 	movl   $0x1070e9,(%esp)
  102ace:	e8 ed d9 ff ff       	call   1004c0 <cprintf>
  e = addr+len;
  for(p = addr; p < e; p += sizeof(struct mp))
  102ad3:	39 f3                	cmp    %esi,%ebx
  102ad5:	73 3a                	jae    102b11 <mpsearch1+0x61>
  102ad7:	90                   	nop
    if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
  102ad8:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  102adf:	00 
  102ae0:	c7 44 24 04 fc 70 10 	movl   $0x1070fc,0x4(%esp)
  102ae7:	00 
  102ae8:	89 1c 24             	mov    %ebx,(%esp)
  102aeb:	e8 90 18 00 00       	call   104380 <memcmp>
  102af0:	85 c0                	test   %eax,%eax
  102af2:	75 16                	jne    102b0a <mpsearch1+0x5a>
  102af4:	31 d2                	xor    %edx,%edx
  102af6:	66 90                	xchg   %ax,%ax
{
  int i, sum;
  
  sum = 0;
  for(i=0; i<len; i++)
    sum += addr[i];
  102af8:	0f b6 0c 03          	movzbl (%ebx,%eax,1),%ecx
sum(uchar *addr, int len)
{
  int i, sum;
  
  sum = 0;
  for(i=0; i<len; i++)
  102afc:	83 c0 01             	add    $0x1,%eax
    sum += addr[i];
  102aff:	01 ca                	add    %ecx,%edx
sum(uchar *addr, int len)
{
  int i, sum;
  
  sum = 0;
  for(i=0; i<len; i++)
  102b01:	83 f8 10             	cmp    $0x10,%eax
  102b04:	75 f2                	jne    102af8 <mpsearch1+0x48>
  uchar *e, *p;

  cprintf("mpsearch1 0x%x %d\n", addr, len);
  e = addr+len;
  for(p = addr; p < e; p += sizeof(struct mp))
    if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
  102b06:	84 d2                	test   %dl,%dl
  102b08:	74 10                	je     102b1a <mpsearch1+0x6a>
{
  uchar *e, *p;

  cprintf("mpsearch1 0x%x %d\n", addr, len);
  e = addr+len;
  for(p = addr; p < e; p += sizeof(struct mp))
  102b0a:	83 c3 10             	add    $0x10,%ebx
  102b0d:	39 de                	cmp    %ebx,%esi
  102b0f:	77 c7                	ja     102ad8 <mpsearch1+0x28>
    if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
      return (struct mp*)p;
  return 0;
}
  102b11:	83 c4 10             	add    $0x10,%esp
{
  uchar *e, *p;

  cprintf("mpsearch1 0x%x %d\n", addr, len);
  e = addr+len;
  for(p = addr; p < e; p += sizeof(struct mp))
  102b14:	31 c0                	xor    %eax,%eax
    if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
      return (struct mp*)p;
  return 0;
}
  102b16:	5b                   	pop    %ebx
  102b17:	5e                   	pop    %esi
  102b18:	5d                   	pop    %ebp
  102b19:	c3                   	ret    
  102b1a:	83 c4 10             	add    $0x10,%esp

  cprintf("mpsearch1 0x%x %d\n", addr, len);
  e = addr+len;
  for(p = addr; p < e; p += sizeof(struct mp))
    if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
      return (struct mp*)p;
  102b1d:	89 d8                	mov    %ebx,%eax
  return 0;
}
  102b1f:	5b                   	pop    %ebx
  102b20:	5e                   	pop    %esi
  102b21:	5d                   	pop    %ebp
  102b22:	c3                   	ret    
  102b23:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  102b29:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00102b30 <mpinit>:
  return conf;
}

void
mpinit(void)
{
  102b30:	55                   	push   %ebp
  102b31:	89 e5                	mov    %esp,%ebp
  102b33:	57                   	push   %edi
  102b34:	56                   	push   %esi
  102b35:	53                   	push   %ebx
  102b36:	83 ec 2c             	sub    $0x2c,%esp
  uchar *bda;
  uint p;
  struct mp *mp;

  bda = (uchar*)0x400;
  if((p = ((bda[0x0F]<<8)|bda[0x0E]) << 4)){
  102b39:	0f b6 05 0f 04 00 00 	movzbl 0x40f,%eax
  102b40:	0f b6 15 0e 04 00 00 	movzbl 0x40e,%edx
  struct mp *mp;
  struct mpconf *conf;
  struct mpproc *proc;
  struct mpioapic *ioapic;

  bcpu = &cpus[0];
  102b47:	c7 05 c4 95 10 00 20 	movl   $0x10c820,0x1095c4
  102b4e:	c8 10 00 
  uchar *bda;
  uint p;
  struct mp *mp;

  bda = (uchar*)0x400;
  if((p = ((bda[0x0F]<<8)|bda[0x0E]) << 4)){
  102b51:	c1 e0 08             	shl    $0x8,%eax
  102b54:	09 d0                	or     %edx,%eax
  102b56:	c1 e0 04             	shl    $0x4,%eax
  102b59:	85 c0                	test   %eax,%eax
  102b5b:	75 1b                	jne    102b78 <mpinit+0x48>
    if((mp = mpsearch1((uchar*)p, 1024)))
      return mp;
  } else {
    p = ((bda[0x14]<<8)|bda[0x13])*1024;
    if((mp = mpsearch1((uchar*)p-1024, 1024)))
  102b5d:	0f b6 05 14 04 00 00 	movzbl 0x414,%eax
  102b64:	0f b6 15 13 04 00 00 	movzbl 0x413,%edx
  102b6b:	c1 e0 08             	shl    $0x8,%eax
  102b6e:	09 d0                	or     %edx,%eax
  102b70:	c1 e0 0a             	shl    $0xa,%eax
  102b73:	2d 00 04 00 00       	sub    $0x400,%eax
  102b78:	ba 00 04 00 00       	mov    $0x400,%edx
  102b7d:	e8 2e ff ff ff       	call   102ab0 <mpsearch1>
  102b82:	85 c0                	test   %eax,%eax
  102b84:	89 c3                	mov    %eax,%ebx
  102b86:	0f 84 54 01 00 00    	je     102ce0 <mpinit+0x1b0>
mpconfig(struct mp **pmp)
{
  struct mpconf *conf;
  struct mp *mp;

  if((mp = mpsearch()) == 0 || mp->physaddr == 0)
  102b8c:	8b 73 04             	mov    0x4(%ebx),%esi
  102b8f:	85 f6                	test   %esi,%esi
  102b91:	74 1c                	je     102baf <mpinit+0x7f>
    return 0;
  conf = (struct mpconf*)mp->physaddr;
  if(memcmp(conf, "PCMP", 4) != 0)
  102b93:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  102b9a:	00 
  102b9b:	c7 44 24 04 01 71 10 	movl   $0x107101,0x4(%esp)
  102ba2:	00 
  102ba3:	89 34 24             	mov    %esi,(%esp)
  102ba6:	e8 d5 17 00 00       	call   104380 <memcmp>
  102bab:	85 c0                	test   %eax,%eax
  102bad:	74 09                	je     102bb8 <mpinit+0x88>
    // Bochs doesn't support IMCR, so this doesn't run on Bochs.
    // But it would on real hardware.
    outb(0x22, 0x70);   // Select IMCR
    outb(0x23, inb(0x23) | 1);  // Mask external interrupts.
  }
}
  102baf:	83 c4 2c             	add    $0x2c,%esp
  102bb2:	5b                   	pop    %ebx
  102bb3:	5e                   	pop    %esi
  102bb4:	5f                   	pop    %edi
  102bb5:	5d                   	pop    %ebp
  102bb6:	c3                   	ret    
  102bb7:	90                   	nop
  if((mp = mpsearch()) == 0 || mp->physaddr == 0)
    return 0;
  conf = (struct mpconf*)mp->physaddr;
  if(memcmp(conf, "PCMP", 4) != 0)
    return 0;
  if(conf->version != 1 && conf->version != 4)
  102bb8:	0f b6 46 06          	movzbl 0x6(%esi),%eax
  102bbc:	3c 04                	cmp    $0x4,%al
  102bbe:	74 04                	je     102bc4 <mpinit+0x94>
  102bc0:	3c 01                	cmp    $0x1,%al
  102bc2:	75 eb                	jne    102baf <mpinit+0x7f>
    return 0;
  if(sum((uchar*)conf, conf->length) != 0)
  102bc4:	0f b7 7e 04          	movzwl 0x4(%esi),%edi
sum(uchar *addr, int len)
{
  int i, sum;
  
  sum = 0;
  for(i=0; i<len; i++)
  102bc8:	85 ff                	test   %edi,%edi
  102bca:	74 15                	je     102be1 <mpinit+0xb1>
  102bcc:	31 d2                	xor    %edx,%edx
  102bce:	31 c0                	xor    %eax,%eax
    sum += addr[i];
  102bd0:	0f b6 0c 06          	movzbl (%esi,%eax,1),%ecx
sum(uchar *addr, int len)
{
  int i, sum;
  
  sum = 0;
  for(i=0; i<len; i++)
  102bd4:	83 c0 01             	add    $0x1,%eax
    sum += addr[i];
  102bd7:	01 ca                	add    %ecx,%edx
sum(uchar *addr, int len)
{
  int i, sum;
  
  sum = 0;
  for(i=0; i<len; i++)
  102bd9:	39 c7                	cmp    %eax,%edi
  102bdb:	7f f3                	jg     102bd0 <mpinit+0xa0>
  conf = (struct mpconf*)mp->physaddr;
  if(memcmp(conf, "PCMP", 4) != 0)
    return 0;
  if(conf->version != 1 && conf->version != 4)
    return 0;
  if(sum((uchar*)conf, conf->length) != 0)
  102bdd:	84 d2                	test   %dl,%dl
  102bdf:	75 ce                	jne    102baf <mpinit+0x7f>
  struct mpioapic *ioapic;

  bcpu = &cpus[0];
  if((conf = mpconfig(&mp)) == 0)
    return;
  ismp = 1;
  102be1:	c7 05 04 c8 10 00 01 	movl   $0x1,0x10c804
  102be8:	00 00 00 
  lapic = (uint*)conf->lapicaddr;
  102beb:	8b 46 24             	mov    0x24(%esi),%eax
  102bee:	a3 f8 c7 10 00       	mov    %eax,0x10c7f8
  for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
  102bf3:	0f b7 4e 04          	movzwl 0x4(%esi),%ecx
  102bf7:	8d 46 2c             	lea    0x2c(%esi),%eax
  102bfa:	8d 0c 0e             	lea    (%esi,%ecx,1),%ecx
  102bfd:	39 c8                	cmp    %ecx,%eax
  102bff:	73 61                	jae    102c62 <mpinit+0x132>
  102c01:	8b 15 c4 95 10 00    	mov    0x1095c4,%edx
  102c07:	89 df                	mov    %ebx,%edi
  102c09:	89 55 e4             	mov    %edx,-0x1c(%ebp)
    switch(*p){
  102c0c:	0f b6 10             	movzbl (%eax),%edx
  102c0f:	80 fa 04             	cmp    $0x4,%dl
  102c12:	76 2c                	jbe    102c40 <mpinit+0x110>
      continue;
    case MPBUS:
    case MPIOINTR:
    case MPLINTR:
      p += 8;
      continue;
  102c14:	8b 45 e4             	mov    -0x1c(%ebp),%eax
    default:
      cprintf("mpinit: unknown config type %x\n", *p);
  102c17:	0f b6 d2             	movzbl %dl,%edx
  102c1a:	89 54 24 04          	mov    %edx,0x4(%esp)
  102c1e:	c7 04 24 28 71 10 00 	movl   $0x107128,(%esp)
      continue;
    case MPBUS:
    case MPIOINTR:
    case MPLINTR:
      p += 8;
      continue;
  102c25:	a3 c4 95 10 00       	mov    %eax,0x1095c4
    default:
      cprintf("mpinit: unknown config type %x\n", *p);
  102c2a:	e8 91 d8 ff ff       	call   1004c0 <cprintf>
      panic("mpinit");
  102c2f:	c7 04 24 21 71 10 00 	movl   $0x107121,(%esp)
  102c36:	e8 25 de ff ff       	call   100a60 <panic>
  102c3b:	90                   	nop
  102c3c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  if((conf = mpconfig(&mp)) == 0)
    return;
  ismp = 1;
  lapic = (uint*)conf->lapicaddr;
  for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
    switch(*p){
  102c40:	0f b6 d2             	movzbl %dl,%edx
  102c43:	ff 24 95 48 71 10 00 	jmp    *0x107148(,%edx,4)
  102c4a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      p += sizeof(struct mpioapic);
      continue;
    case MPBUS:
    case MPIOINTR:
    case MPLINTR:
      p += 8;
  102c50:	83 c0 08             	add    $0x8,%eax
  bcpu = &cpus[0];
  if((conf = mpconfig(&mp)) == 0)
    return;
  ismp = 1;
  lapic = (uint*)conf->lapicaddr;
  for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
  102c53:	39 c1                	cmp    %eax,%ecx
  102c55:	77 b5                	ja     102c0c <mpinit+0xdc>
  102c57:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  102c5a:	89 fb                	mov    %edi,%ebx
  102c5c:	89 15 c4 95 10 00    	mov    %edx,0x1095c4
    default:
      cprintf("mpinit: unknown config type %x\n", *p);
      panic("mpinit");
    }
  }
  if(mp->imcrp){
  102c62:	80 7b 0c 00          	cmpb   $0x0,0xc(%ebx)
  102c66:	0f 84 43 ff ff ff    	je     102baf <mpinit+0x7f>
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  102c6c:	ba 22 00 00 00       	mov    $0x22,%edx
  102c71:	b8 70 00 00 00       	mov    $0x70,%eax
  102c76:	ee                   	out    %al,(%dx)
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  102c77:	b2 23                	mov    $0x23,%dl
  102c79:	ec                   	in     (%dx),%al
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  102c7a:	83 c8 01             	or     $0x1,%eax
  102c7d:	ee                   	out    %al,(%dx)
  102c7e:	e9 2c ff ff ff       	jmp    102baf <mpinit+0x7f>
  102c83:	90                   	nop
  102c84:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  lapic = (uint*)conf->lapicaddr;
  for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
    switch(*p){
    case MPPROC:
      proc = (struct mpproc*)p;
      if(ncpu != proc->apicid) {
  102c88:	0f b6 58 01          	movzbl 0x1(%eax),%ebx
  102c8c:	8b 35 20 ce 10 00    	mov    0x10ce20,%esi
  102c92:	0f b6 d3             	movzbl %bl,%edx
  102c95:	39 f2                	cmp    %esi,%edx
  102c97:	75 68                	jne    102d01 <mpinit+0x1d1>
        cprintf("mpinit: ncpu=%d apicpid=%d", ncpu, proc->apicid);
        panic("mpinit");
      }
      if(proc->flags & MPBOOT)
  102c99:	f6 40 03 02          	testb  $0x2,0x3(%eax)
  102c9d:	74 0f                	je     102cae <mpinit+0x17e>
        bcpu = &cpus[ncpu];
  102c9f:	8d 34 52             	lea    (%edx,%edx,2),%esi
  102ca2:	c1 e6 06             	shl    $0x6,%esi
  102ca5:	81 c6 20 c8 10 00    	add    $0x10c820,%esi
  102cab:	89 75 e4             	mov    %esi,-0x1c(%ebp)
      cpus[ncpu].id = ncpu;
  102cae:	8d 34 52             	lea    (%edx,%edx,2),%esi
      ncpu++;
  102cb1:	83 c2 01             	add    $0x1,%edx
        cprintf("mpinit: ncpu=%d apicpid=%d", ncpu, proc->apicid);
        panic("mpinit");
      }
      if(proc->flags & MPBOOT)
        bcpu = &cpus[ncpu];
      cpus[ncpu].id = ncpu;
  102cb4:	c1 e6 06             	shl    $0x6,%esi
      ncpu++;
      p += sizeof(struct mpproc);
  102cb7:	83 c0 14             	add    $0x14,%eax
        cprintf("mpinit: ncpu=%d apicpid=%d", ncpu, proc->apicid);
        panic("mpinit");
      }
      if(proc->flags & MPBOOT)
        bcpu = &cpus[ncpu];
      cpus[ncpu].id = ncpu;
  102cba:	88 9e 20 c8 10 00    	mov    %bl,0x10c820(%esi)
      ncpu++;
  102cc0:	89 15 20 ce 10 00    	mov    %edx,0x10ce20
      p += sizeof(struct mpproc);
      continue;
  102cc6:	eb 8b                	jmp    102c53 <mpinit+0x123>
    case MPIOAPIC:
      ioapic = (struct mpioapic*)p;
      ioapicid = ioapic->apicno;
  102cc8:	0f b6 50 01          	movzbl 0x1(%eax),%edx
      p += sizeof(struct mpioapic);
  102ccc:	83 c0 08             	add    $0x8,%eax
      ncpu++;
      p += sizeof(struct mpproc);
      continue;
    case MPIOAPIC:
      ioapic = (struct mpioapic*)p;
      ioapicid = ioapic->apicno;
  102ccf:	88 15 00 c8 10 00    	mov    %dl,0x10c800
      p += sizeof(struct mpioapic);
      continue;
  102cd5:	e9 79 ff ff ff       	jmp    102c53 <mpinit+0x123>
  102cda:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  } else {
    p = ((bda[0x14]<<8)|bda[0x13])*1024;
    if((mp = mpsearch1((uchar*)p-1024, 1024)))
      return mp;
  }
  return mpsearch1((uchar*)0xF0000, 0x10000);
  102ce0:	ba 00 00 01 00       	mov    $0x10000,%edx
  102ce5:	b8 00 00 0f 00       	mov    $0xf0000,%eax
  102cea:	e8 c1 fd ff ff       	call   102ab0 <mpsearch1>
mpconfig(struct mp **pmp)
{
  struct mpconf *conf;
  struct mp *mp;

  if((mp = mpsearch()) == 0 || mp->physaddr == 0)
  102cef:	85 c0                	test   %eax,%eax
  } else {
    p = ((bda[0x14]<<8)|bda[0x13])*1024;
    if((mp = mpsearch1((uchar*)p-1024, 1024)))
      return mp;
  }
  return mpsearch1((uchar*)0xF0000, 0x10000);
  102cf1:	89 c3                	mov    %eax,%ebx
mpconfig(struct mp **pmp)
{
  struct mpconf *conf;
  struct mp *mp;

  if((mp = mpsearch()) == 0 || mp->physaddr == 0)
  102cf3:	0f 85 93 fe ff ff    	jne    102b8c <mpinit+0x5c>
    // Bochs doesn't support IMCR, so this doesn't run on Bochs.
    // But it would on real hardware.
    outb(0x22, 0x70);   // Select IMCR
    outb(0x23, inb(0x23) | 1);  // Mask external interrupts.
  }
}
  102cf9:	83 c4 2c             	add    $0x2c,%esp
  102cfc:	5b                   	pop    %ebx
  102cfd:	5e                   	pop    %esi
  102cfe:	5f                   	pop    %edi
  102cff:	5d                   	pop    %ebp
  102d00:	c3                   	ret    
  lapic = (uint*)conf->lapicaddr;
  for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
    switch(*p){
    case MPPROC:
      proc = (struct mpproc*)p;
      if(ncpu != proc->apicid) {
  102d01:	8b 45 e4             	mov    -0x1c(%ebp),%eax
        cprintf("mpinit: ncpu=%d apicpid=%d", ncpu, proc->apicid);
  102d04:	89 54 24 08          	mov    %edx,0x8(%esp)
  102d08:	89 74 24 04          	mov    %esi,0x4(%esp)
  102d0c:	c7 04 24 06 71 10 00 	movl   $0x107106,(%esp)
  lapic = (uint*)conf->lapicaddr;
  for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){
    switch(*p){
    case MPPROC:
      proc = (struct mpproc*)p;
      if(ncpu != proc->apicid) {
  102d13:	a3 c4 95 10 00       	mov    %eax,0x1095c4
        cprintf("mpinit: ncpu=%d apicpid=%d", ncpu, proc->apicid);
  102d18:	e8 a3 d7 ff ff       	call   1004c0 <cprintf>
        panic("mpinit");
  102d1d:	c7 04 24 21 71 10 00 	movl   $0x107121,(%esp)
  102d24:	e8 37 dd ff ff       	call   100a60 <panic>
  102d29:	90                   	nop
  102d2a:	90                   	nop
  102d2b:	90                   	nop
  102d2c:	90                   	nop
  102d2d:	90                   	nop
  102d2e:	90                   	nop
  102d2f:	90                   	nop

00102d30 <picenable>:
  outb(IO_PIC2+1, mask >> 8);
}

void
picenable(int irq)
{
  102d30:	55                   	push   %ebp
  picsetmask(irqmask & ~(1<<irq));
  102d31:	b8 fe ff ff ff       	mov    $0xfffffffe,%eax
  outb(IO_PIC2+1, mask >> 8);
}

void
picenable(int irq)
{
  102d36:	89 e5                	mov    %esp,%ebp
  102d38:	ba 21 00 00 00       	mov    $0x21,%edx
  picsetmask(irqmask & ~(1<<irq));
  102d3d:	8b 4d 08             	mov    0x8(%ebp),%ecx
  102d40:	d3 c0                	rol    %cl,%eax
  102d42:	66 23 05 80 88 10 00 	and    0x108880,%ax
static ushort irqmask = 0xFFFF & ~(1<<IRQ_SLAVE);

static void
picsetmask(ushort mask)
{
  irqmask = mask;
  102d49:	66 a3 80 88 10 00    	mov    %ax,0x108880
  102d4f:	ee                   	out    %al,(%dx)
  102d50:	66 c1 e8 08          	shr    $0x8,%ax
  102d54:	b2 a1                	mov    $0xa1,%dl
  102d56:	ee                   	out    %al,(%dx)

void
picenable(int irq)
{
  picsetmask(irqmask & ~(1<<irq));
}
  102d57:	5d                   	pop    %ebp
  102d58:	c3                   	ret    
  102d59:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00102d60 <picinit>:

// Initialize the 8259A interrupt controllers.
void
picinit(void)
{
  102d60:	55                   	push   %ebp
  102d61:	b9 21 00 00 00       	mov    $0x21,%ecx
  102d66:	89 e5                	mov    %esp,%ebp
  102d68:	83 ec 0c             	sub    $0xc,%esp
  102d6b:	89 1c 24             	mov    %ebx,(%esp)
  102d6e:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  102d73:	89 ca                	mov    %ecx,%edx
  102d75:	89 74 24 04          	mov    %esi,0x4(%esp)
  102d79:	89 7c 24 08          	mov    %edi,0x8(%esp)
  102d7d:	ee                   	out    %al,(%dx)
  102d7e:	bb a1 00 00 00       	mov    $0xa1,%ebx
  102d83:	89 da                	mov    %ebx,%edx
  102d85:	ee                   	out    %al,(%dx)
  102d86:	be 11 00 00 00       	mov    $0x11,%esi
  102d8b:	b2 20                	mov    $0x20,%dl
  102d8d:	89 f0                	mov    %esi,%eax
  102d8f:	ee                   	out    %al,(%dx)
  102d90:	b8 20 00 00 00       	mov    $0x20,%eax
  102d95:	89 ca                	mov    %ecx,%edx
  102d97:	ee                   	out    %al,(%dx)
  102d98:	b8 04 00 00 00       	mov    $0x4,%eax
  102d9d:	ee                   	out    %al,(%dx)
  102d9e:	bf 03 00 00 00       	mov    $0x3,%edi
  102da3:	89 f8                	mov    %edi,%eax
  102da5:	ee                   	out    %al,(%dx)
  102da6:	b1 a0                	mov    $0xa0,%cl
  102da8:	89 f0                	mov    %esi,%eax
  102daa:	89 ca                	mov    %ecx,%edx
  102dac:	ee                   	out    %al,(%dx)
  102dad:	b8 28 00 00 00       	mov    $0x28,%eax
  102db2:	89 da                	mov    %ebx,%edx
  102db4:	ee                   	out    %al,(%dx)
  102db5:	b8 02 00 00 00       	mov    $0x2,%eax
  102dba:	ee                   	out    %al,(%dx)
  102dbb:	89 f8                	mov    %edi,%eax
  102dbd:	ee                   	out    %al,(%dx)
  102dbe:	be 68 00 00 00       	mov    $0x68,%esi
  102dc3:	b2 20                	mov    $0x20,%dl
  102dc5:	89 f0                	mov    %esi,%eax
  102dc7:	ee                   	out    %al,(%dx)
  102dc8:	bb 0a 00 00 00       	mov    $0xa,%ebx
  102dcd:	89 d8                	mov    %ebx,%eax
  102dcf:	ee                   	out    %al,(%dx)
  102dd0:	89 f0                	mov    %esi,%eax
  102dd2:	89 ca                	mov    %ecx,%edx
  102dd4:	ee                   	out    %al,(%dx)
  102dd5:	89 d8                	mov    %ebx,%eax
  102dd7:	ee                   	out    %al,(%dx)
  outb(IO_PIC1, 0x0a);             // read IRR by default

  outb(IO_PIC2, 0x68);             // OCW3
  outb(IO_PIC2, 0x0a);             // OCW3

  if(irqmask != 0xFFFF)
  102dd8:	0f b7 05 80 88 10 00 	movzwl 0x108880,%eax
  102ddf:	66 83 f8 ff          	cmp    $0xffffffff,%ax
  102de3:	74 0a                	je     102def <picinit+0x8f>
  102de5:	b2 21                	mov    $0x21,%dl
  102de7:	ee                   	out    %al,(%dx)
  102de8:	66 c1 e8 08          	shr    $0x8,%ax
  102dec:	b2 a1                	mov    $0xa1,%dl
  102dee:	ee                   	out    %al,(%dx)
    picsetmask(irqmask);
}
  102def:	8b 1c 24             	mov    (%esp),%ebx
  102df2:	8b 74 24 04          	mov    0x4(%esp),%esi
  102df6:	8b 7c 24 08          	mov    0x8(%esp),%edi
  102dfa:	89 ec                	mov    %ebp,%esp
  102dfc:	5d                   	pop    %ebp
  102dfd:	c3                   	ret    
  102dfe:	90                   	nop
  102dff:	90                   	nop

00102e00 <piperead>:
  return n;
}

int
piperead(struct pipe *p, char *addr, int n)
{
  102e00:	55                   	push   %ebp
  102e01:	89 e5                	mov    %esp,%ebp
  102e03:	57                   	push   %edi
  102e04:	56                   	push   %esi
  102e05:	53                   	push   %ebx
  102e06:	83 ec 1c             	sub    $0x1c,%esp
  102e09:	8b 5d 08             	mov    0x8(%ebp),%ebx
  102e0c:	8b 7d 10             	mov    0x10(%ebp),%edi
  int i;

  acquire(&p->lock);
  102e0f:	89 1c 24             	mov    %ebx,(%esp)
  102e12:	e8 a9 14 00 00       	call   1042c0 <acquire>
  while(p->nread == p->nwrite && p->writeopen){  //DOC: pipe-empty
  102e17:	8b 93 34 02 00 00    	mov    0x234(%ebx),%edx
  102e1d:	3b 93 38 02 00 00    	cmp    0x238(%ebx),%edx
  102e23:	75 58                	jne    102e7d <piperead+0x7d>
  102e25:	8b b3 40 02 00 00    	mov    0x240(%ebx),%esi
  102e2b:	85 f6                	test   %esi,%esi
  102e2d:	74 4e                	je     102e7d <piperead+0x7d>
    if(proc->killed){
  102e2f:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
      release(&p->lock);
      return -1;
    }
    sleep(&p->nread, &p->lock); //DOC: piperead-sleep
  102e35:	8d b3 34 02 00 00    	lea    0x234(%ebx),%esi
{
  int i;

  acquire(&p->lock);
  while(p->nread == p->nwrite && p->writeopen){  //DOC: pipe-empty
    if(proc->killed){
  102e3b:	8b 48 24             	mov    0x24(%eax),%ecx
  102e3e:	85 c9                	test   %ecx,%ecx
  102e40:	74 21                	je     102e63 <piperead+0x63>
  102e42:	e9 99 00 00 00       	jmp    102ee0 <piperead+0xe0>
  102e47:	90                   	nop
piperead(struct pipe *p, char *addr, int n)
{
  int i;

  acquire(&p->lock);
  while(p->nread == p->nwrite && p->writeopen){  //DOC: pipe-empty
  102e48:	8b 83 40 02 00 00    	mov    0x240(%ebx),%eax
  102e4e:	85 c0                	test   %eax,%eax
  102e50:	74 2b                	je     102e7d <piperead+0x7d>
    if(proc->killed){
  102e52:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  102e58:	8b 50 24             	mov    0x24(%eax),%edx
  102e5b:	85 d2                	test   %edx,%edx
  102e5d:	0f 85 7d 00 00 00    	jne    102ee0 <piperead+0xe0>
      release(&p->lock);
      return -1;
    }
    sleep(&p->nread, &p->lock); //DOC: piperead-sleep
  102e63:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  102e67:	89 34 24             	mov    %esi,(%esp)
  102e6a:	e8 11 05 00 00       	call   103380 <sleep>
piperead(struct pipe *p, char *addr, int n)
{
  int i;

  acquire(&p->lock);
  while(p->nread == p->nwrite && p->writeopen){  //DOC: pipe-empty
  102e6f:	8b 93 34 02 00 00    	mov    0x234(%ebx),%edx
  102e75:	3b 93 38 02 00 00    	cmp    0x238(%ebx),%edx
  102e7b:	74 cb                	je     102e48 <piperead+0x48>
      release(&p->lock);
      return -1;
    }
    sleep(&p->nread, &p->lock); //DOC: piperead-sleep
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
  102e7d:	85 ff                	test   %edi,%edi
  102e7f:	7e 76                	jle    102ef7 <piperead+0xf7>
    if(p->nread == p->nwrite)
  102e81:	31 f6                	xor    %esi,%esi
  102e83:	3b 93 38 02 00 00    	cmp    0x238(%ebx),%edx
  102e89:	75 0d                	jne    102e98 <piperead+0x98>
  102e8b:	eb 6a                	jmp    102ef7 <piperead+0xf7>
  102e8d:	8d 76 00             	lea    0x0(%esi),%esi
  102e90:	39 93 38 02 00 00    	cmp    %edx,0x238(%ebx)
  102e96:	74 22                	je     102eba <piperead+0xba>
      break;
    addr[i] = p->data[p->nread++ % PIPESIZE];
  102e98:	89 d0                	mov    %edx,%eax
  102e9a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  102e9d:	83 c2 01             	add    $0x1,%edx
  102ea0:	25 ff 01 00 00       	and    $0x1ff,%eax
  102ea5:	0f b6 44 03 34       	movzbl 0x34(%ebx,%eax,1),%eax
  102eaa:	88 04 31             	mov    %al,(%ecx,%esi,1)
      release(&p->lock);
      return -1;
    }
    sleep(&p->nread, &p->lock); //DOC: piperead-sleep
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
  102ead:	83 c6 01             	add    $0x1,%esi
  102eb0:	39 f7                	cmp    %esi,%edi
    if(p->nread == p->nwrite)
      break;
    addr[i] = p->data[p->nread++ % PIPESIZE];
  102eb2:	89 93 34 02 00 00    	mov    %edx,0x234(%ebx)
      release(&p->lock);
      return -1;
    }
    sleep(&p->nread, &p->lock); //DOC: piperead-sleep
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
  102eb8:	7f d6                	jg     102e90 <piperead+0x90>
    if(p->nread == p->nwrite)
      break;
    addr[i] = p->data[p->nread++ % PIPESIZE];
  }
  wakeup(&p->nwrite);  //DOC: piperead-wakeup
  102eba:	8d 83 38 02 00 00    	lea    0x238(%ebx),%eax
  102ec0:	89 04 24             	mov    %eax,(%esp)
  102ec3:	e8 88 03 00 00       	call   103250 <wakeup>
  release(&p->lock);
  102ec8:	89 1c 24             	mov    %ebx,(%esp)
  102ecb:	e8 a0 13 00 00       	call   104270 <release>
  return i;
}
  102ed0:	83 c4 1c             	add    $0x1c,%esp
  102ed3:	89 f0                	mov    %esi,%eax
  102ed5:	5b                   	pop    %ebx
  102ed6:	5e                   	pop    %esi
  102ed7:	5f                   	pop    %edi
  102ed8:	5d                   	pop    %ebp
  102ed9:	c3                   	ret    
  102eda:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  int i;

  acquire(&p->lock);
  while(p->nread == p->nwrite && p->writeopen){  //DOC: pipe-empty
    if(proc->killed){
      release(&p->lock);
  102ee0:	be ff ff ff ff       	mov    $0xffffffff,%esi
  102ee5:	89 1c 24             	mov    %ebx,(%esp)
  102ee8:	e8 83 13 00 00       	call   104270 <release>
    addr[i] = p->data[p->nread++ % PIPESIZE];
  }
  wakeup(&p->nwrite);  //DOC: piperead-wakeup
  release(&p->lock);
  return i;
}
  102eed:	83 c4 1c             	add    $0x1c,%esp
  102ef0:	89 f0                	mov    %esi,%eax
  102ef2:	5b                   	pop    %ebx
  102ef3:	5e                   	pop    %esi
  102ef4:	5f                   	pop    %edi
  102ef5:	5d                   	pop    %ebp
  102ef6:	c3                   	ret    
      release(&p->lock);
      return -1;
    }
    sleep(&p->nread, &p->lock); //DOC: piperead-sleep
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
  102ef7:	31 f6                	xor    %esi,%esi
  102ef9:	eb bf                	jmp    102eba <piperead+0xba>
  102efb:	90                   	nop
  102efc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00102f00 <pipewrite>:
    release(&p->lock);
}

int
pipewrite(struct pipe *p, char *addr, int n)
{
  102f00:	55                   	push   %ebp
  102f01:	89 e5                	mov    %esp,%ebp
  102f03:	57                   	push   %edi
  102f04:	56                   	push   %esi
  102f05:	53                   	push   %ebx
  102f06:	83 ec 3c             	sub    $0x3c,%esp
  102f09:	8b 5d 08             	mov    0x8(%ebp),%ebx
  int i;

  acquire(&p->lock);
  102f0c:	89 1c 24             	mov    %ebx,(%esp)
  102f0f:	8d b3 34 02 00 00    	lea    0x234(%ebx),%esi
  102f15:	e8 a6 13 00 00       	call   1042c0 <acquire>
  for(i = 0; i < n; i++){
  102f1a:	8b 4d 10             	mov    0x10(%ebp),%ecx
  102f1d:	85 c9                	test   %ecx,%ecx
  102f1f:	0f 8e 8d 00 00 00    	jle    102fb2 <pipewrite+0xb2>
  102f25:	8b 83 38 02 00 00    	mov    0x238(%ebx),%eax
      if(p->readopen == 0 || proc->killed){
        release(&p->lock);
        return -1;
      }
      wakeup(&p->nread);
      sleep(&p->nwrite, &p->lock);  //DOC: pipewrite-sleep
  102f2b:	8d bb 38 02 00 00    	lea    0x238(%ebx),%edi
  102f31:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  102f38:	eb 37                	jmp    102f71 <pipewrite+0x71>
  102f3a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  int i;

  acquire(&p->lock);
  for(i = 0; i < n; i++){
    while(p->nwrite == p->nread + PIPESIZE) {  //DOC: pipewrite-full
      if(p->readopen == 0 || proc->killed){
  102f40:	8b 83 3c 02 00 00    	mov    0x23c(%ebx),%eax
  102f46:	85 c0                	test   %eax,%eax
  102f48:	74 7e                	je     102fc8 <pipewrite+0xc8>
  102f4a:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  102f50:	8b 50 24             	mov    0x24(%eax),%edx
  102f53:	85 d2                	test   %edx,%edx
  102f55:	75 71                	jne    102fc8 <pipewrite+0xc8>
        release(&p->lock);
        return -1;
      }
      wakeup(&p->nread);
  102f57:	89 34 24             	mov    %esi,(%esp)
  102f5a:	e8 f1 02 00 00       	call   103250 <wakeup>
      sleep(&p->nwrite, &p->lock);  //DOC: pipewrite-sleep
  102f5f:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  102f63:	89 3c 24             	mov    %edi,(%esp)
  102f66:	e8 15 04 00 00       	call   103380 <sleep>
{
  int i;

  acquire(&p->lock);
  for(i = 0; i < n; i++){
    while(p->nwrite == p->nread + PIPESIZE) {  //DOC: pipewrite-full
  102f6b:	8b 83 38 02 00 00    	mov    0x238(%ebx),%eax
  102f71:	8b 93 34 02 00 00    	mov    0x234(%ebx),%edx
  102f77:	81 c2 00 02 00 00    	add    $0x200,%edx
  102f7d:	39 d0                	cmp    %edx,%eax
  102f7f:	74 bf                	je     102f40 <pipewrite+0x40>
        return -1;
      }
      wakeup(&p->nread);
      sleep(&p->nwrite, &p->lock);  //DOC: pipewrite-sleep
    }
    p->data[p->nwrite++ % PIPESIZE] = addr[i];
  102f81:	89 c2                	mov    %eax,%edx
  102f83:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  102f86:	83 c0 01             	add    $0x1,%eax
  102f89:	81 e2 ff 01 00 00    	and    $0x1ff,%edx
  102f8f:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  102f92:	8b 55 0c             	mov    0xc(%ebp),%edx
  102f95:	0f b6 0c 0a          	movzbl (%edx,%ecx,1),%ecx
  102f99:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  102f9c:	88 4c 13 34          	mov    %cl,0x34(%ebx,%edx,1)
  102fa0:	89 83 38 02 00 00    	mov    %eax,0x238(%ebx)
pipewrite(struct pipe *p, char *addr, int n)
{
  int i;

  acquire(&p->lock);
  for(i = 0; i < n; i++){
  102fa6:	83 45 e4 01          	addl   $0x1,-0x1c(%ebp)
  102faa:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  102fad:	39 4d 10             	cmp    %ecx,0x10(%ebp)
  102fb0:	7f bf                	jg     102f71 <pipewrite+0x71>
      wakeup(&p->nread);
      sleep(&p->nwrite, &p->lock);  //DOC: pipewrite-sleep
    }
    p->data[p->nwrite++ % PIPESIZE] = addr[i];
  }
  wakeup(&p->nread);  //DOC: pipewrite-wakeup1
  102fb2:	89 34 24             	mov    %esi,(%esp)
  102fb5:	e8 96 02 00 00       	call   103250 <wakeup>
  release(&p->lock);
  102fba:	89 1c 24             	mov    %ebx,(%esp)
  102fbd:	e8 ae 12 00 00       	call   104270 <release>
  return n;
  102fc2:	eb 13                	jmp    102fd7 <pipewrite+0xd7>
  102fc4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

  acquire(&p->lock);
  for(i = 0; i < n; i++){
    while(p->nwrite == p->nread + PIPESIZE) {  //DOC: pipewrite-full
      if(p->readopen == 0 || proc->killed){
        release(&p->lock);
  102fc8:	89 1c 24             	mov    %ebx,(%esp)
  102fcb:	e8 a0 12 00 00       	call   104270 <release>
  102fd0:	c7 45 10 ff ff ff ff 	movl   $0xffffffff,0x10(%ebp)
    p->data[p->nwrite++ % PIPESIZE] = addr[i];
  }
  wakeup(&p->nread);  //DOC: pipewrite-wakeup1
  release(&p->lock);
  return n;
}
  102fd7:	8b 45 10             	mov    0x10(%ebp),%eax
  102fda:	83 c4 3c             	add    $0x3c,%esp
  102fdd:	5b                   	pop    %ebx
  102fde:	5e                   	pop    %esi
  102fdf:	5f                   	pop    %edi
  102fe0:	5d                   	pop    %ebp
  102fe1:	c3                   	ret    
  102fe2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  102fe9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00102ff0 <pipeclose>:
  return -1;
}

void
pipeclose(struct pipe *p, int writable)
{
  102ff0:	55                   	push   %ebp
  102ff1:	89 e5                	mov    %esp,%ebp
  102ff3:	83 ec 18             	sub    $0x18,%esp
  102ff6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  102ff9:	8b 5d 08             	mov    0x8(%ebp),%ebx
  102ffc:	89 75 fc             	mov    %esi,-0x4(%ebp)
  102fff:	8b 75 0c             	mov    0xc(%ebp),%esi
  acquire(&p->lock);
  103002:	89 1c 24             	mov    %ebx,(%esp)
  103005:	e8 b6 12 00 00       	call   1042c0 <acquire>
  if(writable){
  10300a:	85 f6                	test   %esi,%esi
  10300c:	74 42                	je     103050 <pipeclose+0x60>
    p->writeopen = 0;
    wakeup(&p->nread);
  10300e:	8d 83 34 02 00 00    	lea    0x234(%ebx),%eax
void
pipeclose(struct pipe *p, int writable)
{
  acquire(&p->lock);
  if(writable){
    p->writeopen = 0;
  103014:	c7 83 40 02 00 00 00 	movl   $0x0,0x240(%ebx)
  10301b:	00 00 00 
    wakeup(&p->nread);
  10301e:	89 04 24             	mov    %eax,(%esp)
  103021:	e8 2a 02 00 00       	call   103250 <wakeup>
  } else {
    p->readopen = 0;
    wakeup(&p->nwrite);
  }
  if(p->readopen == 0 && p->writeopen == 0) {
  103026:	8b 83 3c 02 00 00    	mov    0x23c(%ebx),%eax
  10302c:	85 c0                	test   %eax,%eax
  10302e:	75 0a                	jne    10303a <pipeclose+0x4a>
  103030:	8b b3 40 02 00 00    	mov    0x240(%ebx),%esi
  103036:	85 f6                	test   %esi,%esi
  103038:	74 36                	je     103070 <pipeclose+0x80>
    release(&p->lock);
    kfree((char*)p);
  } else
    release(&p->lock);
  10303a:	89 5d 08             	mov    %ebx,0x8(%ebp)
}
  10303d:	8b 75 fc             	mov    -0x4(%ebp),%esi
  103040:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  103043:	89 ec                	mov    %ebp,%esp
  103045:	5d                   	pop    %ebp
  }
  if(p->readopen == 0 && p->writeopen == 0) {
    release(&p->lock);
    kfree((char*)p);
  } else
    release(&p->lock);
  103046:	e9 25 12 00 00       	jmp    104270 <release>
  10304b:	90                   	nop
  10304c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  if(writable){
    p->writeopen = 0;
    wakeup(&p->nread);
  } else {
    p->readopen = 0;
    wakeup(&p->nwrite);
  103050:	8d 83 38 02 00 00    	lea    0x238(%ebx),%eax
  acquire(&p->lock);
  if(writable){
    p->writeopen = 0;
    wakeup(&p->nread);
  } else {
    p->readopen = 0;
  103056:	c7 83 3c 02 00 00 00 	movl   $0x0,0x23c(%ebx)
  10305d:	00 00 00 
    wakeup(&p->nwrite);
  103060:	89 04 24             	mov    %eax,(%esp)
  103063:	e8 e8 01 00 00       	call   103250 <wakeup>
  103068:	eb bc                	jmp    103026 <pipeclose+0x36>
  10306a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  }
  if(p->readopen == 0 && p->writeopen == 0) {
    release(&p->lock);
  103070:	89 1c 24             	mov    %ebx,(%esp)
  103073:	e8 f8 11 00 00       	call   104270 <release>
    kfree((char*)p);
  } else
    release(&p->lock);
}
  103078:	8b 75 fc             	mov    -0x4(%ebp),%esi
    p->readopen = 0;
    wakeup(&p->nwrite);
  }
  if(p->readopen == 0 && p->writeopen == 0) {
    release(&p->lock);
    kfree((char*)p);
  10307b:	89 5d 08             	mov    %ebx,0x8(%ebp)
  } else
    release(&p->lock);
}
  10307e:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  103081:	89 ec                	mov    %ebp,%esp
  103083:	5d                   	pop    %ebp
    p->readopen = 0;
    wakeup(&p->nwrite);
  }
  if(p->readopen == 0 && p->writeopen == 0) {
    release(&p->lock);
    kfree((char*)p);
  103084:	e9 b7 f3 ff ff       	jmp    102440 <kfree>
  103089:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00103090 <pipealloc>:
  int writeopen;  // write fd is still open
};

int
pipealloc(struct file **f0, struct file **f1)
{
  103090:	55                   	push   %ebp
  103091:	89 e5                	mov    %esp,%ebp
  103093:	57                   	push   %edi
  103094:	56                   	push   %esi
  103095:	53                   	push   %ebx
  103096:	83 ec 1c             	sub    $0x1c,%esp
  103099:	8b 75 08             	mov    0x8(%ebp),%esi
  10309c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  struct pipe *p;

  p = 0;
  *f0 = *f1 = 0;
  10309f:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  1030a5:	c7 06 00 00 00 00    	movl   $0x0,(%esi)
  if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
  1030ab:	e8 e0 df ff ff       	call   101090 <filealloc>
  1030b0:	85 c0                	test   %eax,%eax
  1030b2:	89 06                	mov    %eax,(%esi)
  1030b4:	0f 84 9c 00 00 00    	je     103156 <pipealloc+0xc6>
  1030ba:	e8 d1 df ff ff       	call   101090 <filealloc>
  1030bf:	85 c0                	test   %eax,%eax
  1030c1:	89 03                	mov    %eax,(%ebx)
  1030c3:	0f 84 7f 00 00 00    	je     103148 <pipealloc+0xb8>
    goto bad;
  if((p = (struct pipe*)kalloc()) == 0)
  1030c9:	e8 32 f3 ff ff       	call   102400 <kalloc>
  1030ce:	85 c0                	test   %eax,%eax
  1030d0:	89 c7                	mov    %eax,%edi
  1030d2:	74 74                	je     103148 <pipealloc+0xb8>
    goto bad;
  p->readopen = 1;
  1030d4:	c7 80 3c 02 00 00 01 	movl   $0x1,0x23c(%eax)
  1030db:	00 00 00 
  p->writeopen = 1;
  1030de:	c7 80 40 02 00 00 01 	movl   $0x1,0x240(%eax)
  1030e5:	00 00 00 
  p->nwrite = 0;
  1030e8:	c7 80 38 02 00 00 00 	movl   $0x0,0x238(%eax)
  1030ef:	00 00 00 
  p->nread = 0;
  1030f2:	c7 80 34 02 00 00 00 	movl   $0x0,0x234(%eax)
  1030f9:	00 00 00 
  initlock(&p->lock, "pipe");
  1030fc:	89 04 24             	mov    %eax,(%esp)
  1030ff:	c7 44 24 04 5c 71 10 	movl   $0x10715c,0x4(%esp)
  103106:	00 
  103107:	e8 24 10 00 00       	call   104130 <initlock>
  (*f0)->type = FD_PIPE;
  10310c:	8b 06                	mov    (%esi),%eax
  10310e:	c7 00 01 00 00 00    	movl   $0x1,(%eax)
  (*f0)->readable = 1;
  103114:	8b 06                	mov    (%esi),%eax
  103116:	c6 40 08 01          	movb   $0x1,0x8(%eax)
  (*f0)->writable = 0;
  10311a:	8b 06                	mov    (%esi),%eax
  10311c:	c6 40 09 00          	movb   $0x0,0x9(%eax)
  (*f0)->pipe = p;
  103120:	8b 06                	mov    (%esi),%eax
  103122:	89 78 0c             	mov    %edi,0xc(%eax)
  (*f1)->type = FD_PIPE;
  103125:	8b 03                	mov    (%ebx),%eax
  103127:	c7 00 01 00 00 00    	movl   $0x1,(%eax)
  (*f1)->readable = 0;
  10312d:	8b 03                	mov    (%ebx),%eax
  10312f:	c6 40 08 00          	movb   $0x0,0x8(%eax)
  (*f1)->writable = 1;
  103133:	8b 03                	mov    (%ebx),%eax
  103135:	c6 40 09 01          	movb   $0x1,0x9(%eax)
  (*f1)->pipe = p;
  103139:	8b 03                	mov    (%ebx),%eax
  10313b:	89 78 0c             	mov    %edi,0xc(%eax)
  10313e:	31 c0                	xor    %eax,%eax
  if(*f0)
    fileclose(*f0);
  if(*f1)
    fileclose(*f1);
  return -1;
}
  103140:	83 c4 1c             	add    $0x1c,%esp
  103143:	5b                   	pop    %ebx
  103144:	5e                   	pop    %esi
  103145:	5f                   	pop    %edi
  103146:	5d                   	pop    %ebp
  103147:	c3                   	ret    
  return 0;

 bad:
  if(p)
    kfree((char*)p);
  if(*f0)
  103148:	8b 06                	mov    (%esi),%eax
  10314a:	85 c0                	test   %eax,%eax
  10314c:	74 08                	je     103156 <pipealloc+0xc6>
    fileclose(*f0);
  10314e:	89 04 24             	mov    %eax,(%esp)
  103151:	e8 ba df ff ff       	call   101110 <fileclose>
  if(*f1)
  103156:	8b 13                	mov    (%ebx),%edx
  103158:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  10315d:	85 d2                	test   %edx,%edx
  10315f:	74 df                	je     103140 <pipealloc+0xb0>
    fileclose(*f1);
  103161:	89 14 24             	mov    %edx,(%esp)
  103164:	e8 a7 df ff ff       	call   101110 <fileclose>
  103169:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  10316e:	eb d0                	jmp    103140 <pipealloc+0xb0>

00103170 <nice>:
 }


int
nice(void){
    if (proc->priority > 0){
  103170:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  103177:	b8 ff ff ff ff       	mov    $0xffffffff,%eax

 }


int
nice(void){
  10317c:	55                   	push   %ebp
  10317d:	89 e5                	mov    %esp,%ebp
    if (proc->priority > 0){
  10317f:	8b 8a 88 00 00 00    	mov    0x88(%edx),%ecx
  103185:	85 c9                	test   %ecx,%ecx
  103187:	7e 1b                	jle    1031a4 <nice+0x34>
    	proc->priority = proc->priority - 1;
  103189:	83 e9 01             	sub    $0x1,%ecx
  10318c:	89 8a 88 00 00 00    	mov    %ecx,0x88(%edx)
	proc->runtimeFactor = 2;
  103192:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103198:	c7 80 8c 00 00 00 02 	movl   $0x2,0x8c(%eax)
  10319f:	00 00 00 
  1031a2:	31 c0                	xor    %eax,%eax
	return 0;
    }
    return -1; 
}
  1031a4:	5d                   	pop    %ebp
  1031a5:	c3                   	ret    
  1031a6:	8d 76 00             	lea    0x0(%esi),%esi
  1031a9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001031b0 <kill>:
// Kill the process with the given pid.
// Process won't exit until it returns
// to user space (see trap in trap.c).
int
kill(int pid)
{
  1031b0:	55                   	push   %ebp
  1031b1:	89 e5                	mov    %esp,%ebp
  1031b3:	56                   	push   %esi
  1031b4:	53                   	push   %ebx

// Kill the process with the given pid.
// Process won't exit until it returns
// to user space (see trap in trap.c).
int
kill(int pid)
  1031b5:	bb 04 cf 10 00       	mov    $0x10cf04,%ebx
{
  1031ba:	83 ec 10             	sub    $0x10,%esp
  1031bd:	8b 75 08             	mov    0x8(%ebp),%esi
  struct proc *p;

  acquire(&ptable.lock);
  1031c0:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1031c7:	e8 f4 10 00 00       	call   1042c0 <acquire>
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    if(p->pid == pid){
  1031cc:	a1 84 ce 10 00       	mov    0x10ce84,%eax
  1031d1:	39 f0                	cmp    %esi,%eax
  1031d3:	75 11                	jne    1031e6 <kill+0x36>
  1031d5:	eb 71                	jmp    103248 <kill+0x98>
  1031d7:	90                   	nop
kill(int pid)
{
  struct proc *p;

  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  1031d8:	81 c3 90 00 00 00    	add    $0x90,%ebx
  1031de:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  1031e4:	74 4a                	je     103230 <kill+0x80>
    if(p->pid == pid){
  1031e6:	8b 43 10             	mov    0x10(%ebx),%eax
  1031e9:	39 f0                	cmp    %esi,%eax
  1031eb:	75 eb                	jne    1031d8 <kill+0x28>
      p->killed = 1;
  1031ed:	c7 43 24 01 00 00 00 	movl   $0x1,0x24(%ebx)
      p->etime = sys_uptime();
  1031f4:	e8 b7 20 00 00       	call   1052b0 <sys_uptime>
      // Wake process from sleep if necessary.
      if(p->state == SLEEPING)
  1031f9:	83 7b 0c 02          	cmpl   $0x2,0xc(%ebx)

  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    if(p->pid == pid){
      p->killed = 1;
      p->etime = sys_uptime();
  1031fd:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
      // Wake process from sleep if necessary.
      if(p->state == SLEEPING)
  103203:	74 1b                	je     103220 <kill+0x70>
        p->state = RUNNABLE;
      release(&ptable.lock);
  103205:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  10320c:	e8 5f 10 00 00       	call   104270 <release>
      return 0;
    }
  }
  release(&ptable.lock);
  return -1;
}
  103211:	83 c4 10             	add    $0x10,%esp
      p->killed = 1;
      p->etime = sys_uptime();
      // Wake process from sleep if necessary.
      if(p->state == SLEEPING)
        p->state = RUNNABLE;
      release(&ptable.lock);
  103214:	31 c0                	xor    %eax,%eax
      return 0;
    }
  }
  release(&ptable.lock);
  return -1;
}
  103216:	5b                   	pop    %ebx
  103217:	5e                   	pop    %esi
  103218:	5d                   	pop    %ebp
  103219:	c3                   	ret    
  10321a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    if(p->pid == pid){
      p->killed = 1;
      p->etime = sys_uptime();
      // Wake process from sleep if necessary.
      if(p->state == SLEEPING)
        p->state = RUNNABLE;
  103220:	c7 43 0c 03 00 00 00 	movl   $0x3,0xc(%ebx)
  103227:	eb dc                	jmp    103205 <kill+0x55>
  103229:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
      release(&ptable.lock);
      return 0;
    }
  }
  release(&ptable.lock);
  103230:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103237:	e8 34 10 00 00       	call   104270 <release>
  return -1;
}
  10323c:	83 c4 10             	add    $0x10,%esp
        p->state = RUNNABLE;
      release(&ptable.lock);
      return 0;
    }
  }
  release(&ptable.lock);
  10323f:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  return -1;
}
  103244:	5b                   	pop    %ebx
  103245:	5e                   	pop    %esi
  103246:	5d                   	pop    %ebp
  103247:	c3                   	ret    
{
  struct proc *p;

  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    if(p->pid == pid){
  103248:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
  10324d:	eb 9e                	jmp    1031ed <kill+0x3d>
  10324f:	90                   	nop

00103250 <wakeup>:
}

// Wake up all processes sleeping on chan.
void
wakeup(void *chan)
{
  103250:	55                   	push   %ebp
  103251:	89 e5                	mov    %esp,%ebp
  103253:	53                   	push   %ebx
  103254:	83 ec 14             	sub    $0x14,%esp
  103257:	8b 5d 08             	mov    0x8(%ebp),%ebx
  acquire(&ptable.lock);
  10325a:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103261:	e8 5a 10 00 00       	call   1042c0 <acquire>
      p->state = RUNNABLE;
}

// Wake up all processes sleeping on chan.
void
wakeup(void *chan)
  103266:	b8 74 ce 10 00       	mov    $0x10ce74,%eax
  10326b:	eb 0f                	jmp    10327c <wakeup+0x2c>
  10326d:	8d 76 00             	lea    0x0(%esi),%esi
static void
wakeup1(void *chan)
{
  struct proc *p;

  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  103270:	05 90 00 00 00       	add    $0x90,%eax
  103275:	3d 74 f2 10 00       	cmp    $0x10f274,%eax
  10327a:	74 24                	je     1032a0 <wakeup+0x50>
    if(p->state == SLEEPING && p->chan == chan)
  10327c:	83 78 0c 02          	cmpl   $0x2,0xc(%eax)
  103280:	75 ee                	jne    103270 <wakeup+0x20>
  103282:	3b 58 20             	cmp    0x20(%eax),%ebx
  103285:	75 e9                	jne    103270 <wakeup+0x20>
      p->state = RUNNABLE;
  103287:	c7 40 0c 03 00 00 00 	movl   $0x3,0xc(%eax)
static void
wakeup1(void *chan)
{
  struct proc *p;

  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  10328e:	05 90 00 00 00       	add    $0x90,%eax
  103293:	3d 74 f2 10 00       	cmp    $0x10f274,%eax
  103298:	75 e2                	jne    10327c <wakeup+0x2c>
  10329a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
void
wakeup(void *chan)
{
  acquire(&ptable.lock);
  wakeup1(chan);
  release(&ptable.lock);
  1032a0:	c7 45 08 40 ce 10 00 	movl   $0x10ce40,0x8(%ebp)
}
  1032a7:	83 c4 14             	add    $0x14,%esp
  1032aa:	5b                   	pop    %ebx
  1032ab:	5d                   	pop    %ebp
void
wakeup(void *chan)
{
  acquire(&ptable.lock);
  wakeup1(chan);
  release(&ptable.lock);
  1032ac:	e9 bf 0f 00 00       	jmp    104270 <release>
  1032b1:	eb 0d                	jmp    1032c0 <forkret>
  1032b3:	90                   	nop
  1032b4:	90                   	nop
  1032b5:	90                   	nop
  1032b6:	90                   	nop
  1032b7:	90                   	nop
  1032b8:	90                   	nop
  1032b9:	90                   	nop
  1032ba:	90                   	nop
  1032bb:	90                   	nop
  1032bc:	90                   	nop
  1032bd:	90                   	nop
  1032be:	90                   	nop
  1032bf:	90                   	nop

001032c0 <forkret>:

// A fork child's very first scheduling by scheduler()
// will swtch here.  "Return" to user space.
void
forkret(void)
{
  1032c0:	55                   	push   %ebp
  1032c1:	89 e5                	mov    %esp,%ebp
  1032c3:	83 ec 18             	sub    $0x18,%esp
  // Still holding ptable.lock from scheduler.
  release(&ptable.lock);
  1032c6:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1032cd:	e8 9e 0f 00 00       	call   104270 <release>
  
  // Return to "caller", actually trapret (see allocproc).
}
  1032d2:	c9                   	leave  
  1032d3:	c3                   	ret    
  1032d4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  1032da:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

001032e0 <sched>:

// Enter scheduler.  Must hold only ptable.lock
// and have changed proc->state.
void
sched(void)
{
  1032e0:	55                   	push   %ebp
  1032e1:	89 e5                	mov    %esp,%ebp
  1032e3:	53                   	push   %ebx
  1032e4:	83 ec 14             	sub    $0x14,%esp
  int intena;

  if(!holding(&ptable.lock))
  1032e7:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1032ee:	e8 bd 0e 00 00       	call   1041b0 <holding>
  1032f3:	85 c0                	test   %eax,%eax
  1032f5:	74 4d                	je     103344 <sched+0x64>
    panic("sched ptable.lock");
  if(cpu->ncli != 1)
  1032f7:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  1032fd:	83 b8 ac 00 00 00 01 	cmpl   $0x1,0xac(%eax)
  103304:	75 62                	jne    103368 <sched+0x88>
    panic("sched locks");
  if(proc->state == RUNNING)
  103306:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  10330d:	83 7a 0c 04          	cmpl   $0x4,0xc(%edx)
  103311:	74 49                	je     10335c <sched+0x7c>

static inline uint
readeflags(void)
{
  uint eflags;
  asm volatile("pushfl; popl %0" : "=r" (eflags));
  103313:	9c                   	pushf  
  103314:	59                   	pop    %ecx
    panic("sched running");
  if(readeflags()&FL_IF)
  103315:	80 e5 02             	and    $0x2,%ch
  103318:	75 36                	jne    103350 <sched+0x70>
    panic("sched interruptible");
  intena = cpu->intena;
  10331a:	8b 98 b0 00 00 00    	mov    0xb0(%eax),%ebx
  swtch(&proc->context, cpu->scheduler);
  103320:	83 c2 1c             	add    $0x1c,%edx
  103323:	8b 40 04             	mov    0x4(%eax),%eax
  103326:	89 14 24             	mov    %edx,(%esp)
  103329:	89 44 24 04          	mov    %eax,0x4(%esp)
  10332d:	e8 2a 12 00 00       	call   10455c <swtch>
  cpu->intena = intena;
  103332:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  103338:	89 98 b0 00 00 00    	mov    %ebx,0xb0(%eax)
}
  10333e:	83 c4 14             	add    $0x14,%esp
  103341:	5b                   	pop    %ebx
  103342:	5d                   	pop    %ebp
  103343:	c3                   	ret    
sched(void)
{
  int intena;

  if(!holding(&ptable.lock))
    panic("sched ptable.lock");
  103344:	c7 04 24 61 71 10 00 	movl   $0x107161,(%esp)
  10334b:	e8 10 d7 ff ff       	call   100a60 <panic>
  if(cpu->ncli != 1)
    panic("sched locks");
  if(proc->state == RUNNING)
    panic("sched running");
  if(readeflags()&FL_IF)
    panic("sched interruptible");
  103350:	c7 04 24 8d 71 10 00 	movl   $0x10718d,(%esp)
  103357:	e8 04 d7 ff ff       	call   100a60 <panic>
  if(!holding(&ptable.lock))
    panic("sched ptable.lock");
  if(cpu->ncli != 1)
    panic("sched locks");
  if(proc->state == RUNNING)
    panic("sched running");
  10335c:	c7 04 24 7f 71 10 00 	movl   $0x10717f,(%esp)
  103363:	e8 f8 d6 ff ff       	call   100a60 <panic>
  int intena;

  if(!holding(&ptable.lock))
    panic("sched ptable.lock");
  if(cpu->ncli != 1)
    panic("sched locks");
  103368:	c7 04 24 73 71 10 00 	movl   $0x107173,(%esp)
  10336f:	e8 ec d6 ff ff       	call   100a60 <panic>
  103374:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  10337a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00103380 <sleep>:

// Atomically release lock and sleep on chan.
// Reacquires lock when awakened.
void
sleep(void *chan, struct spinlock *lk)
{
  103380:	55                   	push   %ebp
  103381:	89 e5                	mov    %esp,%ebp
  103383:	56                   	push   %esi
  103384:	53                   	push   %ebx
  103385:	83 ec 10             	sub    $0x10,%esp
  if(proc == 0)
  103388:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax

// Atomically release lock and sleep on chan.
// Reacquires lock when awakened.
void
sleep(void *chan, struct spinlock *lk)
{
  10338e:	8b 75 08             	mov    0x8(%ebp),%esi
  103391:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  if(proc == 0)
  103394:	85 c0                	test   %eax,%eax
  103396:	0f 84 a1 00 00 00    	je     10343d <sleep+0xbd>
    panic("sleep");

  if(lk == 0)
  10339c:	85 db                	test   %ebx,%ebx
  10339e:	0f 84 8d 00 00 00    	je     103431 <sleep+0xb1>
  // change p->state and then call sched.
  // Once we hold ptable.lock, we can be
  // guaranteed that we won't miss any wakeup
  // (wakeup runs with ptable.lock locked),
  // so it's okay to release lk.
  if(lk != &ptable.lock){  //DOC: sleeplock0
  1033a4:	81 fb 40 ce 10 00    	cmp    $0x10ce40,%ebx
  1033aa:	74 5c                	je     103408 <sleep+0x88>
    acquire(&ptable.lock);  //DOC: sleeplock1
  1033ac:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1033b3:	e8 08 0f 00 00       	call   1042c0 <acquire>
    release(lk);
  1033b8:	89 1c 24             	mov    %ebx,(%esp)
  1033bb:	e8 b0 0e 00 00       	call   104270 <release>
  }

  // Go to sleep.
  proc->chan = chan;
  1033c0:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1033c6:	89 70 20             	mov    %esi,0x20(%eax)
  proc->state = SLEEPING;
  1033c9:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1033cf:	c7 40 0c 02 00 00 00 	movl   $0x2,0xc(%eax)
  sched();
  1033d6:	e8 05 ff ff ff       	call   1032e0 <sched>

  // Tidy up.
  proc->chan = 0;
  1033db:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1033e1:	c7 40 20 00 00 00 00 	movl   $0x0,0x20(%eax)

  // Reacquire original lock.
  if(lk != &ptable.lock){  //DOC: sleeplock2
    release(&ptable.lock);
  1033e8:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1033ef:	e8 7c 0e 00 00       	call   104270 <release>
    acquire(lk);
  1033f4:	89 5d 08             	mov    %ebx,0x8(%ebp)
  }
}
  1033f7:	83 c4 10             	add    $0x10,%esp
  1033fa:	5b                   	pop    %ebx
  1033fb:	5e                   	pop    %esi
  1033fc:	5d                   	pop    %ebp
  proc->chan = 0;

  // Reacquire original lock.
  if(lk != &ptable.lock){  //DOC: sleeplock2
    release(&ptable.lock);
    acquire(lk);
  1033fd:	e9 be 0e 00 00       	jmp    1042c0 <acquire>
  103402:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    acquire(&ptable.lock);  //DOC: sleeplock1
    release(lk);
  }

  // Go to sleep.
  proc->chan = chan;
  103408:	89 70 20             	mov    %esi,0x20(%eax)
  proc->state = SLEEPING;
  10340b:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103411:	c7 40 0c 02 00 00 00 	movl   $0x2,0xc(%eax)
  sched();
  103418:	e8 c3 fe ff ff       	call   1032e0 <sched>

  // Tidy up.
  proc->chan = 0;
  10341d:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103423:	c7 40 20 00 00 00 00 	movl   $0x0,0x20(%eax)
  // Reacquire original lock.
  if(lk != &ptable.lock){  //DOC: sleeplock2
    release(&ptable.lock);
    acquire(lk);
  }
}
  10342a:	83 c4 10             	add    $0x10,%esp
  10342d:	5b                   	pop    %ebx
  10342e:	5e                   	pop    %esi
  10342f:	5d                   	pop    %ebp
  103430:	c3                   	ret    
{
  if(proc == 0)
    panic("sleep");

  if(lk == 0)
    panic("sleep without lk");
  103431:	c7 04 24 a7 71 10 00 	movl   $0x1071a7,(%esp)
  103438:	e8 23 d6 ff ff       	call   100a60 <panic>
// Reacquires lock when awakened.
void
sleep(void *chan, struct spinlock *lk)
{
  if(proc == 0)
    panic("sleep");
  10343d:	c7 04 24 a1 71 10 00 	movl   $0x1071a1,(%esp)
  103444:	e8 17 d6 ff ff       	call   100a60 <panic>
  103449:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00103450 <yield>:
}

// Give up the CPU for one scheduling round.
void
yield(void)
{
  103450:	55                   	push   %ebp
  103451:	89 e5                	mov    %esp,%ebp
  103453:	83 ec 18             	sub    $0x18,%esp
  acquire(&ptable.lock);  //DOC: yieldlock
  103456:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  10345d:	e8 5e 0e 00 00       	call   1042c0 <acquire>
  proc->state = RUNNABLE;
  103462:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103468:	c7 40 0c 03 00 00 00 	movl   $0x3,0xc(%eax)
  
  sched();
  10346f:	e8 6c fe ff ff       	call   1032e0 <sched>
  release(&ptable.lock);
  103474:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  10347b:	e8 f0 0d 00 00       	call   104270 <release>
}
  103480:	c9                   	leave  
  103481:	c3                   	ret    
  103482:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  103489:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00103490 <schedulerFAIR2Q>:
}
		


void
schedulerFAIR2Q(void){
  103490:	55                   	push   %ebp
  103491:	89 e5                	mov    %esp,%ebp
  103493:	57                   	push   %edi
  103494:	56                   	push   %esi
  103495:	53                   	push   %ebx
  103496:	31 db                	xor    %ebx,%ebx
  103498:	83 ec 2c             	sub    $0x2c,%esp
}

static inline void
sti(void)
{
  asm volatile("sti");
  10349b:	fb                   	sti    
	 for( ; ; ){
    // Enable interrupts on this processor.
    sti();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
  10349c:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1034a3:	31 f6                	xor    %esi,%esi
  1034a5:	e8 16 0e 00 00       	call   1042c0 <acquire>
  1034aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    
	for (i=0; i<NPROC; i++){
		minTime = 10000;
 		currTime = sys_uptime();
  1034b0:	e8 fb 1d 00 00       	call   1052b0 <sys_uptime>
}
		


void
schedulerFAIR2Q(void){
  1034b5:	ba 74 ce 10 00       	mov    $0x10ce74,%edx
    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
	for (i=0; i<NPROC; i++){
		minTime = 10000;
 		currTime = sys_uptime();
  1034ba:	89 c1                	mov    %eax,%ecx
}
		


void
schedulerFAIR2Q(void){
  1034bc:	d9 05 4c 72 10 00    	flds   0x10724c
  1034c2:	eb 1a                	jmp    1034de <schedulerFAIR2Q+0x4e>
  1034c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1034c8:	dd d9                	fstp   %st(1)
  1034ca:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    acquire(&ptable.lock);
    
	for (i=0; i<NPROC; i++){
		minTime = 10000;
 		currTime = sys_uptime();
		for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){	
  1034d0:	81 c2 90 00 00 00    	add    $0x90,%edx
  1034d6:	81 fa 74 f2 10 00    	cmp    $0x10f274,%edx
  1034dc:	74 4a                	je     103528 <schedulerFAIR2Q+0x98>
			if(p->state != RUNNABLE || p->priority !=1)
  1034de:	83 7a 0c 03          	cmpl   $0x3,0xc(%edx)
  1034e2:	75 ec                	jne    1034d0 <schedulerFAIR2Q+0x40>
  1034e4:	83 ba 88 00 00 00 01 	cmpl   $0x1,0x88(%edx)
  1034eb:	75 e3                	jne    1034d0 <schedulerFAIR2Q+0x40>
				continue;
        if (p->ctime != currTime){
  1034ed:	8b 42 7c             	mov    0x7c(%edx),%eax
  1034f0:	39 c1                	cmp    %eax,%ecx
  1034f2:	74 dc                	je     1034d0 <schedulerFAIR2Q+0x40>
 			tmpTime = (double)p->rtime / ( currTime - p->ctime);
  1034f4:	89 cf                	mov    %ecx,%edi
  1034f6:	db 82 80 00 00 00    	fildl  0x80(%edx)
  1034fc:	29 c7                	sub    %eax,%edi
  1034fe:	89 7d e4             	mov    %edi,-0x1c(%ebp)
  103501:	db 45 e4             	fildl  -0x1c(%ebp)
  103504:	de f9                	fdivrp %st,%st(1)
  103506:	d9 c9                	fxch   %st(1)
			if (tmpTime < minTime){
  103508:	dd e1                	fucom  %st(1)
  10350a:	df e0                	fnstsw %ax
  10350c:	9e                   	sahf   
  10350d:	76 b9                	jbe    1034c8 <schedulerFAIR2Q+0x38>
  10350f:	dd d8                	fstp   %st(0)
  103511:	89 d3                	mov    %edx,%ebx
    acquire(&ptable.lock);
    
	for (i=0; i<NPROC; i++){
		minTime = 10000;
 		currTime = sys_uptime();
		for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){	
  103513:	81 c2 90 00 00 00    	add    $0x90,%edx
  103519:	81 fa 74 f2 10 00    	cmp    $0x10f274,%edx
  10351f:	75 bd                	jne    1034de <schedulerFAIR2Q+0x4e>
  103521:	dd d8                	fstp   %st(0)
  103523:	eb 05                	jmp    10352a <schedulerFAIR2Q+0x9a>
  103525:	8d 76 00             	lea    0x0(%esi),%esi
  103528:	dd d8                	fstp   %st(0)
      // Switch to chosen process (with priority 1.  It is the process's job
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      
      p = min; 
      proc = p;
  10352a:	65 89 1d 04 00 00 00 	mov    %ebx,%gs:0x4
    sti();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
	for (i=0; i<NPROC; i++){
  103531:	83 c6 01             	add    $0x1,%esi
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      
      p = min; 
      proc = p;
      switchuvm(p);
  103534:	89 1c 24             	mov    %ebx,(%esp)
  103537:	e8 44 35 00 00       	call   106a80 <switchuvm>
     
      p->state = RUNNING;
  10353c:	c7 43 0c 04 00 00 00 	movl   $0x4,0xc(%ebx)
      startTime = sys_uptime();
  103543:	e8 68 1d 00 00       	call   1052b0 <sys_uptime>
  103548:	89 45 e0             	mov    %eax,-0x20(%ebp)
      swtch(&cpu->scheduler, proc->context);
  10354b:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103551:	8b 40 1c             	mov    0x1c(%eax),%eax
  103554:	89 44 24 04          	mov    %eax,0x4(%esp)
  103558:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  10355e:	83 c0 04             	add    $0x4,%eax
  103561:	89 04 24             	mov    %eax,(%esp)
  103564:	e8 f3 0f 00 00       	call   10455c <swtch>
      switchkvm();
  103569:	e8 e2 2e 00 00       	call   106450 <switchkvm>

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc->rtime = proc->rtime + (sys_uptime() - startTime);
  10356e:	65 8b 3d 04 00 00 00 	mov    %gs:0x4,%edi
  103575:	8b 87 80 00 00 00    	mov    0x80(%edi),%eax
  10357b:	89 45 dc             	mov    %eax,-0x24(%ebp)
  10357e:	e8 2d 1d 00 00       	call   1052b0 <sys_uptime>
  103583:	03 45 dc             	add    -0x24(%ebp),%eax
  103586:	2b 45 e0             	sub    -0x20(%ebp),%eax
    sti();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
	for (i=0; i<NPROC; i++){
  103589:	83 fe 40             	cmp    $0x40,%esi
      swtch(&cpu->scheduler, proc->context);
      switchkvm();

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc->rtime = proc->rtime + (sys_uptime() - startTime);
  10358c:	89 87 80 00 00 00    	mov    %eax,0x80(%edi)
      proc = 0;
  103592:	65 c7 05 04 00 00 00 	movl   $0x0,%gs:0x4
  103599:	00 00 00 00 
    sti();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
	for (i=0; i<NPROC; i++){
  10359d:	0f 85 0d ff ff ff    	jne    1034b0 <schedulerFAIR2Q+0x20>
    }
	


	minTime = 100000;
	currTime = sys_uptime();
  1035a3:	e8 08 1d 00 00       	call   1052b0 <sys_uptime>
}
		


void
schedulerFAIR2Q(void){
  1035a8:	ba 74 ce 10 00       	mov    $0x10ce74,%edx
    }
	


	minTime = 100000;
	currTime = sys_uptime();
  1035ad:	89 c1                	mov    %eax,%ecx
}
		


void
schedulerFAIR2Q(void){
  1035af:	d9 05 50 72 10 00    	flds   0x107250
  1035b5:	eb 17                	jmp    1035ce <schedulerFAIR2Q+0x13e>
  1035b7:	dd d9                	fstp   %st(1)
  1035b9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
	


	minTime = 100000;
	currTime = sys_uptime();
		for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){	
  1035c0:	81 c2 90 00 00 00    	add    $0x90,%edx
  1035c6:	81 fa 74 f2 10 00    	cmp    $0x10f274,%edx
  1035cc:	74 38                	je     103606 <schedulerFAIR2Q+0x176>
			if(p->state != RUNNABLE || p->priority !=0)
  1035ce:	83 7a 0c 03          	cmpl   $0x3,0xc(%edx)
  1035d2:	75 ec                	jne    1035c0 <schedulerFAIR2Q+0x130>
  1035d4:	8b 82 88 00 00 00    	mov    0x88(%edx),%eax
  1035da:	85 c0                	test   %eax,%eax
  1035dc:	75 e2                	jne    1035c0 <schedulerFAIR2Q+0x130>
				continue;
        if (p->ctime != currTime){
  1035de:	8b 42 7c             	mov    0x7c(%edx),%eax
  1035e1:	39 c1                	cmp    %eax,%ecx
  1035e3:	74 db                	je     1035c0 <schedulerFAIR2Q+0x130>
 			tmpTime = (double)p->rtime / ( currTime - p->ctime);
  1035e5:	89 ce                	mov    %ecx,%esi
  1035e7:	db 82 80 00 00 00    	fildl  0x80(%edx)
  1035ed:	29 c6                	sub    %eax,%esi
  1035ef:	89 75 e4             	mov    %esi,-0x1c(%ebp)
  1035f2:	db 45 e4             	fildl  -0x1c(%ebp)
  1035f5:	de f9                	fdivrp %st,%st(1)
  1035f7:	d9 c9                	fxch   %st(1)
			if (tmpTime < minTime){
  1035f9:	dd e1                	fucom  %st(1)
  1035fb:	df e0                	fnstsw %ax
  1035fd:	9e                   	sahf   
  1035fe:	76 b7                	jbe    1035b7 <schedulerFAIR2Q+0x127>
  103600:	dd d8                	fstp   %st(0)
  103602:	89 d3                	mov    %edx,%ebx
  103604:	eb ba                	jmp    1035c0 <schedulerFAIR2Q+0x130>
	}

      // Switch to chosen process (with priority 1.  It is the process's job
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      if (minTime != 100000) {
  103606:	d9 05 50 72 10 00    	flds   0x107250
  10360c:	d9 c9                	fxch   %st(1)
  10360e:	da e9                	fucompp 
  103610:	df e0                	fnstsw %ax
  103612:	9e                   	sahf   
  103613:	7a 13                	jp     103628 <schedulerFAIR2Q+0x198>
  103615:	75 11                	jne    103628 <schedulerFAIR2Q+0x198>
      proc = 0;
  }
      
    
    
    release(&ptable.lock);
  103617:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  10361e:	e8 4d 0c 00 00       	call   104270 <release>
  }		
  103623:	e9 73 fe ff ff       	jmp    10349b <schedulerFAIR2Q+0xb>
      // Switch to chosen process (with priority 1.  It is the process's job
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      if (minTime != 100000) {
      p = min; 
      proc = p;
  103628:	65 89 1d 04 00 00 00 	mov    %ebx,%gs:0x4
      switchuvm(p);
  10362f:	89 1c 24             	mov    %ebx,(%esp)
  103632:	e8 49 34 00 00       	call   106a80 <switchuvm>
     
      p->state = RUNNING;
  103637:	c7 43 0c 04 00 00 00 	movl   $0x4,0xc(%ebx)
      startTime = sys_uptime();
  10363e:	e8 6d 1c 00 00       	call   1052b0 <sys_uptime>
  103643:	89 c7                	mov    %eax,%edi
      swtch(&cpu->scheduler, proc->context);
  103645:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  10364b:	8b 40 1c             	mov    0x1c(%eax),%eax
  10364e:	89 44 24 04          	mov    %eax,0x4(%esp)
  103652:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  103658:	83 c0 04             	add    $0x4,%eax
  10365b:	89 04 24             	mov    %eax,(%esp)
  10365e:	e8 f9 0e 00 00       	call   10455c <swtch>
      switchkvm();
  103663:	e8 e8 2d 00 00       	call   106450 <switchkvm>

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc->rtime = proc->rtime + (sys_uptime() - startTime);
  103668:	65 8b 35 04 00 00 00 	mov    %gs:0x4,%esi
  10366f:	8b 86 80 00 00 00    	mov    0x80(%esi),%eax
  103675:	89 45 e0             	mov    %eax,-0x20(%ebp)
  103678:	e8 33 1c 00 00       	call   1052b0 <sys_uptime>
  10367d:	03 45 e0             	add    -0x20(%ebp),%eax
  103680:	29 f8                	sub    %edi,%eax
  103682:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
      proc = 0;
  103688:	65 c7 05 04 00 00 00 	movl   $0x0,%gs:0x4
  10368f:	00 00 00 00 
  103693:	eb 82                	jmp    103617 <schedulerFAIR2Q+0x187>
  103695:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  103699:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001036a0 <scheduler>:
//  - swtch to start running that process
//  - eventually that process transfers control
//      via swtch back to the scheduler.
void
scheduler(void)
{
  1036a0:	55                   	push   %ebp
  1036a1:	89 e5                	mov    %esp,%ebp
  1036a3:	57                   	push   %edi
  1036a4:	56                   	push   %esi
  1036a5:	53                   	push   %ebx
  1036a6:	83 ec 2c             	sub    $0x2c,%esp
  struct proc *p;
 int startTime;

#ifdef FAIR2Q
	schedulerFAIR2Q();
  1036a9:	e8 e2 fd ff ff       	call   103490 <schedulerFAIR2Q>
  1036ae:	66 90                	xchg   %ax,%ax
  1036b0:	fb                   	sti    
//  - choose a process to run
//  - swtch to start running that process
//  - eventually that process transfers control
//      via swtch back to the scheduler.
void
scheduler(void)
  1036b1:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
  for( ; ; ){
    // Enable interrupts on this processor.
    sti();

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
  1036b6:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1036bd:	e8 fe 0b 00 00       	call   1042c0 <acquire>
  1036c2:	eb 16                	jmp    1036da <scheduler+0x3a>
  1036c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    
//original schedualing - start
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  1036c8:	81 c3 90 00 00 00    	add    $0x90,%ebx
  1036ce:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  1036d4:	0f 84 86 00 00 00    	je     103760 <scheduler+0xc0>
      if(p->state != RUNNABLE)
  1036da:	83 7b 0c 03          	cmpl   $0x3,0xc(%ebx)
  1036de:	66 90                	xchg   %ax,%ax
  1036e0:	75 e6                	jne    1036c8 <scheduler+0x28>
        continue;

      // Switch to chosen process (with priority 1.  It is the process's job
      // to release ptable.lock and then reacquire it
      // before jumping back to us.
      proc = p;
  1036e2:	65 89 1d 04 00 00 00 	mov    %ebx,%gs:0x4
      switchuvm(p);
  1036e9:	89 1c 24             	mov    %ebx,(%esp)
  1036ec:	e8 8f 33 00 00       	call   106a80 <switchuvm>
     
      p->state = RUNNING;
  1036f1:	c7 43 0c 04 00 00 00 	movl   $0x4,0xc(%ebx)

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
//original schedualing - start
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  1036f8:	81 c3 90 00 00 00    	add    $0x90,%ebx
      // before jumping back to us.
      proc = p;
      switchuvm(p);
     
      p->state = RUNNING;
      startTime = sys_uptime();
  1036fe:	e8 ad 1b 00 00       	call   1052b0 <sys_uptime>
  103703:	89 c7                	mov    %eax,%edi
      swtch(&cpu->scheduler, proc->context);
  103705:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  10370b:	8b 40 1c             	mov    0x1c(%eax),%eax
  10370e:	89 44 24 04          	mov    %eax,0x4(%esp)
  103712:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  103718:	83 c0 04             	add    $0x4,%eax
  10371b:	89 04 24             	mov    %eax,(%esp)
  10371e:	e8 39 0e 00 00       	call   10455c <swtch>
      switchkvm();
  103723:	e8 28 2d 00 00       	call   106450 <switchkvm>

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc->rtime = proc->rtime + (sys_uptime() - startTime);
  103728:	65 8b 35 04 00 00 00 	mov    %gs:0x4,%esi
  10372f:	8b 86 80 00 00 00    	mov    0x80(%esi),%eax
  103735:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  103738:	e8 73 1b 00 00       	call   1052b0 <sys_uptime>
  10373d:	03 45 e4             	add    -0x1c(%ebp),%eax
  103740:	29 f8                	sub    %edi,%eax

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
//original schedualing - start
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103742:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
      swtch(&cpu->scheduler, proc->context);
      switchkvm();

      // Process is done running for now.
      // It should have changed its p->state before coming back.
      proc->rtime = proc->rtime + (sys_uptime() - startTime);
  103748:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
      proc = 0;
  10374e:	65 c7 05 04 00 00 00 	movl   $0x0,%gs:0x4
  103755:	00 00 00 00 

    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    
//original schedualing - start
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103759:	0f 85 7b ff ff ff    	jne    1036da <scheduler+0x3a>
  10375f:	90                   	nop


//RRQ2 scheduling - end


    release(&ptable.lock);
  103760:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103767:	e8 04 0b 00 00       	call   104270 <release>

  }
  10376c:	e9 3f ff ff ff       	jmp    1036b0 <scheduler+0x10>
  103771:	eb 0d                	jmp    103780 <schedulerRR2Q>
  103773:	90                   	nop
  103774:	90                   	nop
  103775:	90                   	nop
  103776:	90                   	nop
  103777:	90                   	nop
  103778:	90                   	nop
  103779:	90                   	nop
  10377a:	90                   	nop
  10377b:	90                   	nop
  10377c:	90                   	nop
  10377d:	90                   	nop
  10377e:	90                   	nop
  10377f:	90                   	nop

00103780 <schedulerRR2Q>:
}


void
schedulerRR2Q(void)
{
  103780:	55                   	push   %ebp
  103781:	89 e5                	mov    %esp,%ebp
  103783:	57                   	push   %edi
  103784:	56                   	push   %esi
  103785:	53                   	push   %ebx
  103786:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
  10378b:	83 ec 2c             	sub    $0x2c,%esp
  10378e:	89 5d dc             	mov    %ebx,-0x24(%ebp)
  103791:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  103798:	fb                   	sti    
 
  for( ; ; ){
    // Enable interrupts on this processor.
    sti();
    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
  103799:	be 01 00 00 00       	mov    $0x1,%esi
  10379e:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1037a5:	e8 16 0b 00 00       	call   1042c0 <acquire>
  1037aa:	eb 22                	jmp    1037ce <schedulerRR2Q+0x4e>
  1037ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
		proc = 0;
		
		counter = counter + 1;
		p = p+1;
  1037b0:	81 c3 90 00 00 00    	add    $0x90,%ebx
		if (p == &ptable.proc[NPROC])
  1037b6:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  1037bc:	0f 84 9e 00 00 00    	je     103860 <schedulerRR2Q+0xe0>
  1037c2:	83 c6 01             	add    $0x1,%esi
    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    p = start1;
    counter = 0;

      while(counter < NPROC){
  1037c5:	83 fe 41             	cmp    $0x41,%esi
  1037c8:	0f 84 aa 00 00 00    	je     103878 <schedulerRR2Q+0xf8>
		
		if(p->state != RUNNABLE || p->priority !=1){
  1037ce:	83 7b 0c 03          	cmpl   $0x3,0xc(%ebx)
  1037d2:	75 dc                	jne    1037b0 <schedulerRR2Q+0x30>
  1037d4:	83 bb 88 00 00 00 01 	cmpl   $0x1,0x88(%ebx)
  1037db:	75 d3                	jne    1037b0 <schedulerRR2Q+0x30>
		
		// Switch to chosen process (with priority 1.  It is the process's job
		// to release ptable.lock and then reacquire it
		// before jumping back to us.
		
		proc = p;
  1037dd:	65 89 1d 04 00 00 00 	mov    %ebx,%gs:0x4
		switchuvm(p);
  1037e4:	89 1c 24             	mov    %ebx,(%esp)
  1037e7:	e8 94 32 00 00       	call   106a80 <switchuvm>
		
		p->state = RUNNING;
  1037ec:	c7 43 0c 04 00 00 00 	movl   $0x4,0xc(%ebx)
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
		proc = 0;
		
		counter = counter + 1;
		p = p+1;
  1037f3:	81 c3 90 00 00 00    	add    $0x90,%ebx
		
		proc = p;
		switchuvm(p);
		
		p->state = RUNNING;
		startTime = sys_uptime();
  1037f9:	e8 b2 1a 00 00       	call   1052b0 <sys_uptime>
  1037fe:	89 45 e4             	mov    %eax,-0x1c(%ebp)
		swtch(&cpu->scheduler, proc->context);
  103801:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103807:	8b 40 1c             	mov    0x1c(%eax),%eax
  10380a:	89 44 24 04          	mov    %eax,0x4(%esp)
  10380e:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  103814:	83 c0 04             	add    $0x4,%eax
  103817:	89 04 24             	mov    %eax,(%esp)
  10381a:	e8 3d 0d 00 00       	call   10455c <swtch>
		switchkvm();
  10381f:	e8 2c 2c 00 00       	call   106450 <switchkvm>
		
		// Process is done running for now.
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
  103824:	65 8b 3d 04 00 00 00 	mov    %gs:0x4,%edi
  10382b:	8b 87 80 00 00 00    	mov    0x80(%edi),%eax
  103831:	89 45 e0             	mov    %eax,-0x20(%ebp)
  103834:	e8 77 1a 00 00       	call   1052b0 <sys_uptime>
  103839:	03 45 e0             	add    -0x20(%ebp),%eax
  10383c:	2b 45 e4             	sub    -0x1c(%ebp),%eax
		proc = 0;
		
		counter = counter + 1;
		p = p+1;
		if (p == &ptable.proc[NPROC])
  10383f:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
		swtch(&cpu->scheduler, proc->context);
		switchkvm();
		
		// Process is done running for now.
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
  103845:	89 87 80 00 00 00    	mov    %eax,0x80(%edi)
		proc = 0;
  10384b:	65 c7 05 04 00 00 00 	movl   $0x0,%gs:0x4
  103852:	00 00 00 00 
		
		counter = counter + 1;
		p = p+1;
		if (p == &ptable.proc[NPROC])
  103856:	0f 85 66 ff ff ff    	jne    1037c2 <schedulerRR2Q+0x42>
  10385c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  103860:	83 c6 01             	add    $0x1,%esi
  103863:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
    // Loop over process table looking for process to run.
    acquire(&ptable.lock);
    p = start1;
    counter = 0;

      while(counter < NPROC){
  103868:	83 fe 41             	cmp    $0x41,%esi
  10386b:	0f 85 5d ff ff ff    	jne    1037ce <schedulerRR2Q+0x4e>
  103871:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  103878:	8b 75 dc             	mov    -0x24(%ebp),%esi
  10387b:	31 c0                	xor    %eax,%eax
  10387d:	eb 1f                	jmp    10389e <schedulerRR2Q+0x11e>
  10387f:	90                   	nop


   while(counter < NPROC){
		
		if(p->state != RUNNABLE || p->priority !=0){
			p = p + 1;
  103880:	81 c6 90 00 00 00    	add    $0x90,%esi
			counter = counter + 1;
  103886:	83 c0 01             	add    $0x1,%eax
			if (p == &ptable.proc[NPROC])
  103889:	81 fe 74 f2 10 00    	cmp    $0x10f274,%esi
  10388f:	0f 84 ab 00 00 00    	je     103940 <schedulerRR2Q+0x1c0>
	start1 = p;
	counter = 0;
        p = start0;


   while(counter < NPROC){
  103895:	83 f8 40             	cmp    $0x40,%eax
  103898:	0f 84 8b 00 00 00    	je     103929 <schedulerRR2Q+0x1a9>
		
		if(p->state != RUNNABLE || p->priority !=0){
  10389e:	83 7e 0c 03          	cmpl   $0x3,0xc(%esi)
  1038a2:	75 dc                	jne    103880 <schedulerRR2Q+0x100>
  1038a4:	8b 96 88 00 00 00    	mov    0x88(%esi),%edx
  1038aa:	85 d2                	test   %edx,%edx
  1038ac:	75 d2                	jne    103880 <schedulerRR2Q+0x100>
		
		// Switch to chosen process (with priority 1.  It is the process's job
		// to release ptable.lock and then reacquire it
		// before jumping back to us.
		
		proc = p;
  1038ae:	65 89 35 04 00 00 00 	mov    %esi,%gs:0x4
		switchuvm(p);
  1038b5:	89 34 24             	mov    %esi,(%esp)
  1038b8:	e8 c3 31 00 00       	call   106a80 <switchuvm>
		
		p->state = RUNNING;
  1038bd:	c7 46 0c 04 00 00 00 	movl   $0x4,0xc(%esi)
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
		proc = 0;
		
		counter = counter + 1;
		p = p+1;
  1038c4:	81 c6 90 00 00 00    	add    $0x90,%esi
		
		proc = p;
		switchuvm(p);
		
		p->state = RUNNING;
		startTime = sys_uptime();
  1038ca:	e8 e1 19 00 00       	call   1052b0 <sys_uptime>
  1038cf:	89 45 e0             	mov    %eax,-0x20(%ebp)
		swtch(&cpu->scheduler, proc->context);
  1038d2:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1038d8:	8b 40 1c             	mov    0x1c(%eax),%eax
  1038db:	89 44 24 04          	mov    %eax,0x4(%esp)
  1038df:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  1038e5:	83 c0 04             	add    $0x4,%eax
  1038e8:	89 04 24             	mov    %eax,(%esp)
  1038eb:	e8 6c 0c 00 00       	call   10455c <swtch>
		switchkvm();
  1038f0:	e8 5b 2b 00 00       	call   106450 <switchkvm>
		
		// Process is done running for now.
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
  1038f5:	65 8b 3d 04 00 00 00 	mov    %gs:0x4,%edi
  1038fc:	8b 87 80 00 00 00    	mov    0x80(%edi),%eax
  103902:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  103905:	e8 a6 19 00 00       	call   1052b0 <sys_uptime>
  10390a:	03 45 e4             	add    -0x1c(%ebp),%eax
  10390d:	2b 45 e0             	sub    -0x20(%ebp),%eax
		proc = 0;
		
		counter = counter + 1;
		p = p+1;
		if (p == &ptable.proc[NPROC])
  103910:	81 fe 74 f2 10 00    	cmp    $0x10f274,%esi
		swtch(&cpu->scheduler, proc->context);
		switchkvm();
		
		// Process is done running for now.
		// It should have changed its p->state before coming back.
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
  103916:	89 87 80 00 00 00    	mov    %eax,0x80(%edi)
		proc = 0;
  10391c:	65 c7 05 04 00 00 00 	movl   $0x0,%gs:0x4
  103923:	00 00 00 00 
		
		counter = counter + 1;
		p = p+1;
		if (p == &ptable.proc[NPROC])
  103927:	74 21                	je     10394a <schedulerRR2Q+0x1ca>
		break;

		} //end of for loop that looks for a P with priority==1
	
	start0 = p;
	release(&ptable.lock);
  103929:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103930:	e8 3b 09 00 00       	call   104270 <release>
  103935:	89 75 dc             	mov    %esi,-0x24(%ebp)
  }
  103938:	e9 5b fe ff ff       	jmp    103798 <schedulerRR2Q+0x18>
  10393d:	8d 76 00             	lea    0x0(%esi),%esi
   while(counter < NPROC){
		
		if(p->state != RUNNABLE || p->priority !=0){
			p = p + 1;
			counter = counter + 1;
			if (p == &ptable.proc[NPROC])
  103940:	be 74 ce 10 00       	mov    $0x10ce74,%esi
  103945:	e9 4b ff ff ff       	jmp    103895 <schedulerRR2Q+0x115>
		proc->rtime = proc->rtime + (sys_uptime() - startTime);
		proc = 0;
		
		counter = counter + 1;
		p = p+1;
		if (p == &ptable.proc[NPROC])
  10394a:	be 74 ce 10 00       	mov    $0x10ce74,%esi
  10394f:	eb d8                	jmp    103929 <schedulerRR2Q+0x1a9>
  103951:	eb 0d                	jmp    103960 <wait2>
  103953:	90                   	nop
  103954:	90                   	nop
  103955:	90                   	nop
  103956:	90                   	nop
  103957:	90                   	nop
  103958:	90                   	nop
  103959:	90                   	nop
  10395a:	90                   	nop
  10395b:	90                   	nop
  10395c:	90                   	nop
  10395d:	90                   	nop
  10395e:	90                   	nop
  10395f:	90                   	nop

00103960 <wait2>:



int
wait2(int *wtime, int *rtime)
{
  103960:	55                   	push   %ebp
  103961:	89 e5                	mov    %esp,%ebp
  103963:	53                   	push   %ebx
	struct proc *p;
	int havekids, pid;

	acquire(&ptable.lock);
  103964:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx



int
wait2(int *wtime, int *rtime)
{
  103969:	83 ec 24             	sub    $0x24,%esp
	struct proc *p;
	int havekids, pid;

	acquire(&ptable.lock);
  10396c:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103973:	e8 48 09 00 00       	call   1042c0 <acquire>
  103978:	31 c0                	xor    %eax,%eax
  10397a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
	for(;;){
    // Scan through table looking for zombie children.
		havekids = 0;
		for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103980:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  103986:	72 30                	jb     1039b8 <wait2+0x58>
				return pid;
			}
		}

    // No point waiting if we don't have any children.
		if(!havekids || proc->killed){
  103988:	85 c0                	test   %eax,%eax
  10398a:	74 5c                	je     1039e8 <wait2+0x88>
  10398c:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103992:	8b 48 24             	mov    0x24(%eax),%ecx
  103995:	85 c9                	test   %ecx,%ecx
  103997:	75 4f                	jne    1039e8 <wait2+0x88>
			release(&ptable.lock);
			return -1;
		}

    // Wait for children to exit.  (See wakeup1 call in proc_exit.)
		sleep(proc, &ptable.lock);  //DOC: wait-sleep
  103999:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
  10399e:	89 04 24             	mov    %eax,(%esp)
  1039a1:	c7 44 24 04 40 ce 10 	movl   $0x10ce40,0x4(%esp)
  1039a8:	00 
  1039a9:	e8 d2 f9 ff ff       	call   103380 <sleep>
  1039ae:	31 c0                	xor    %eax,%eax

	acquire(&ptable.lock);
	for(;;){
    // Scan through table looking for zombie children.
		havekids = 0;
		for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  1039b0:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  1039b6:	73 d0                	jae    103988 <wait2+0x28>
			if(p->parent != proc)
  1039b8:	8b 53 14             	mov    0x14(%ebx),%edx
  1039bb:	65 3b 15 04 00 00 00 	cmp    %gs:0x4,%edx
  1039c2:	74 0c                	je     1039d0 <wait2+0x70>

	acquire(&ptable.lock);
	for(;;){
    // Scan through table looking for zombie children.
		havekids = 0;
		for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  1039c4:	81 c3 90 00 00 00    	add    $0x90,%ebx
  1039ca:	eb b4                	jmp    103980 <wait2+0x20>
  1039cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
			if(p->parent != proc)
				continue;
			havekids = 1;
			if(p->state == ZOMBIE){
  1039d0:	83 7b 0c 05          	cmpl   $0x5,0xc(%ebx)
  1039d4:	74 29                	je     1039ff <wait2+0x9f>
				p->killed = 0;
				*wtime = p->etime - p->ctime - p->rtime;
				*rtime = p->rtime;
				//cprintf("wtime: %d ; rtime: %d", *wtime, *rtime);
				release(&ptable.lock);
				return pid;
  1039d6:	b8 01 00 00 00       	mov    $0x1,%eax
  1039db:	90                   	nop
  1039dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1039e0:	eb e2                	jmp    1039c4 <wait2+0x64>
  1039e2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
			}
		}

    // No point waiting if we don't have any children.
		if(!havekids || proc->killed){
			release(&ptable.lock);
  1039e8:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  1039ef:	e8 7c 08 00 00       	call   104270 <release>
  1039f4:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
		}

    // Wait for children to exit.  (See wakeup1 call in proc_exit.)
		sleep(proc, &ptable.lock);  //DOC: wait-sleep
	}
}
  1039f9:	83 c4 24             	add    $0x24,%esp
  1039fc:	5b                   	pop    %ebx
  1039fd:	5d                   	pop    %ebp
  1039fe:	c3                   	ret    
			if(p->parent != proc)
				continue;
			havekids = 1;
			if(p->state == ZOMBIE){
        // Found one.
				pid = p->pid;
  1039ff:	8b 43 10             	mov    0x10(%ebx),%eax
				kfree(p->kstack);
  103a02:	8b 53 08             	mov    0x8(%ebx),%edx
  103a05:	89 45 f4             	mov    %eax,-0xc(%ebp)
  103a08:	89 14 24             	mov    %edx,(%esp)
  103a0b:	e8 30 ea ff ff       	call   102440 <kfree>
				p->kstack = 0;
				freevm(p->pgdir);
  103a10:	8b 53 04             	mov    0x4(%ebx),%edx
			havekids = 1;
			if(p->state == ZOMBIE){
        // Found one.
				pid = p->pid;
				kfree(p->kstack);
				p->kstack = 0;
  103a13:	c7 43 08 00 00 00 00 	movl   $0x0,0x8(%ebx)
				freevm(p->pgdir);
  103a1a:	89 14 24             	mov    %edx,(%esp)
  103a1d:	e8 8e 2d 00 00       	call   1067b0 <freevm>
				p->state = UNUSED;
				p->pid = 0;
				p->parent = 0;
				p->name[0] = 0;
				p->killed = 0;
				*wtime = p->etime - p->ctime - p->rtime;
  103a22:	8b 93 84 00 00 00    	mov    0x84(%ebx),%edx
  103a28:	8b 4d 08             	mov    0x8(%ebp),%ecx
  103a2b:	2b 53 7c             	sub    0x7c(%ebx),%edx
  103a2e:	2b 93 80 00 00 00    	sub    0x80(%ebx),%edx
        // Found one.
				pid = p->pid;
				kfree(p->kstack);
				p->kstack = 0;
				freevm(p->pgdir);
				p->state = UNUSED;
  103a34:	c7 43 0c 00 00 00 00 	movl   $0x0,0xc(%ebx)
				p->pid = 0;
  103a3b:	c7 43 10 00 00 00 00 	movl   $0x0,0x10(%ebx)
				p->parent = 0;
  103a42:	c7 43 14 00 00 00 00 	movl   $0x0,0x14(%ebx)
				p->name[0] = 0;
  103a49:	c6 43 6c 00          	movb   $0x0,0x6c(%ebx)
				p->killed = 0;
  103a4d:	c7 43 24 00 00 00 00 	movl   $0x0,0x24(%ebx)
				*wtime = p->etime - p->ctime - p->rtime;
  103a54:	89 11                	mov    %edx,(%ecx)
				*rtime = p->rtime;
  103a56:	8b 8b 80 00 00 00    	mov    0x80(%ebx),%ecx
  103a5c:	8b 55 0c             	mov    0xc(%ebp),%edx
  103a5f:	89 0a                	mov    %ecx,(%edx)
				//cprintf("wtime: %d ; rtime: %d", *wtime, *rtime);
				release(&ptable.lock);
  103a61:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103a68:	e8 03 08 00 00       	call   104270 <release>
				return pid;
  103a6d:	8b 45 f4             	mov    -0xc(%ebp),%eax
  103a70:	eb 87                	jmp    1039f9 <wait2+0x99>
  103a72:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  103a79:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00103a80 <wait>:

// Wait for a child process to exit and return its pid.
// Return -1 if this process has no children.
int
wait(void)
{
  103a80:	55                   	push   %ebp
  103a81:	89 e5                	mov    %esp,%ebp
  103a83:	53                   	push   %ebx
  struct proc *p;
  int havekids, pid;

  acquire(&ptable.lock);
  103a84:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx

// Wait for a child process to exit and return its pid.
// Return -1 if this process has no children.
int
wait(void)
{
  103a89:	83 ec 24             	sub    $0x24,%esp
  struct proc *p;
  int havekids, pid;

  acquire(&ptable.lock);
  103a8c:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103a93:	e8 28 08 00 00       	call   1042c0 <acquire>
  103a98:	31 c0                	xor    %eax,%eax
  103a9a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  for(;;){
    // Scan through table looking for zombie children.
    havekids = 0;
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103aa0:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  103aa6:	72 30                	jb     103ad8 <wait+0x58>
        return pid;
      }
    }

    // No point waiting if we don't have any children.
    if(!havekids || proc->killed){
  103aa8:	85 c0                	test   %eax,%eax
  103aaa:	74 5c                	je     103b08 <wait+0x88>
  103aac:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103ab2:	8b 58 24             	mov    0x24(%eax),%ebx
  103ab5:	85 db                	test   %ebx,%ebx
  103ab7:	75 4f                	jne    103b08 <wait+0x88>
      release(&ptable.lock);
      return -1;
    }

    // Wait for children to exit.  (See wakeup1 call in proc_exit.)
    sleep(proc, &ptable.lock);  //DOC: wait-sleep
  103ab9:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
  103abe:	89 04 24             	mov    %eax,(%esp)
  103ac1:	c7 44 24 04 40 ce 10 	movl   $0x10ce40,0x4(%esp)
  103ac8:	00 
  103ac9:	e8 b2 f8 ff ff       	call   103380 <sleep>
  103ace:	31 c0                	xor    %eax,%eax

  acquire(&ptable.lock);
  for(;;){
    // Scan through table looking for zombie children.
    havekids = 0;
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103ad0:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  103ad6:	73 d0                	jae    103aa8 <wait+0x28>
      if(p->parent != proc)
  103ad8:	8b 53 14             	mov    0x14(%ebx),%edx
  103adb:	65 3b 15 04 00 00 00 	cmp    %gs:0x4,%edx
  103ae2:	74 0c                	je     103af0 <wait+0x70>

  acquire(&ptable.lock);
  for(;;){
    // Scan through table looking for zombie children.
    havekids = 0;
    for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103ae4:	81 c3 90 00 00 00    	add    $0x90,%ebx
  103aea:	eb b4                	jmp    103aa0 <wait+0x20>
  103aec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
      if(p->parent != proc)
        continue;
      havekids = 1;
      if(p->state == ZOMBIE){
  103af0:	83 7b 0c 05          	cmpl   $0x5,0xc(%ebx)
  103af4:	74 29                	je     103b1f <wait+0x9f>
        p->pid = 0;
        p->parent = 0;
        p->name[0] = 0;
        p->killed = 0;
        release(&ptable.lock);
        return pid;
  103af6:	b8 01 00 00 00       	mov    $0x1,%eax
  103afb:	90                   	nop
  103afc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  103b00:	eb e2                	jmp    103ae4 <wait+0x64>
  103b02:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      }
    }

    // No point waiting if we don't have any children.
    if(!havekids || proc->killed){
      release(&ptable.lock);
  103b08:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103b0f:	e8 5c 07 00 00       	call   104270 <release>
  103b14:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    }

    // Wait for children to exit.  (See wakeup1 call in proc_exit.)
    sleep(proc, &ptable.lock);  //DOC: wait-sleep
  }
}
  103b19:	83 c4 24             	add    $0x24,%esp
  103b1c:	5b                   	pop    %ebx
  103b1d:	5d                   	pop    %ebp
  103b1e:	c3                   	ret    
      if(p->parent != proc)
        continue;
      havekids = 1;
      if(p->state == ZOMBIE){
        // Found one.
        pid = p->pid;
  103b1f:	8b 43 10             	mov    0x10(%ebx),%eax
        kfree(p->kstack);
  103b22:	8b 53 08             	mov    0x8(%ebx),%edx
  103b25:	89 45 f4             	mov    %eax,-0xc(%ebp)
  103b28:	89 14 24             	mov    %edx,(%esp)
  103b2b:	e8 10 e9 ff ff       	call   102440 <kfree>
        p->kstack = 0;
        freevm(p->pgdir);
  103b30:	8b 53 04             	mov    0x4(%ebx),%edx
      havekids = 1;
      if(p->state == ZOMBIE){
        // Found one.
        pid = p->pid;
        kfree(p->kstack);
        p->kstack = 0;
  103b33:	c7 43 08 00 00 00 00 	movl   $0x0,0x8(%ebx)
        freevm(p->pgdir);
  103b3a:	89 14 24             	mov    %edx,(%esp)
  103b3d:	e8 6e 2c 00 00       	call   1067b0 <freevm>
        p->state = UNUSED;
  103b42:	c7 43 0c 00 00 00 00 	movl   $0x0,0xc(%ebx)
        p->pid = 0;
  103b49:	c7 43 10 00 00 00 00 	movl   $0x0,0x10(%ebx)
        p->parent = 0;
  103b50:	c7 43 14 00 00 00 00 	movl   $0x0,0x14(%ebx)
        p->name[0] = 0;
  103b57:	c6 43 6c 00          	movb   $0x0,0x6c(%ebx)
        p->killed = 0;
  103b5b:	c7 43 24 00 00 00 00 	movl   $0x0,0x24(%ebx)
        release(&ptable.lock);
  103b62:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103b69:	e8 02 07 00 00       	call   104270 <release>
        return pid;
  103b6e:	8b 45 f4             	mov    -0xc(%ebp),%eax
  103b71:	eb a6                	jmp    103b19 <wait+0x99>
  103b73:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  103b79:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00103b80 <exit>:
// Exit the current process.  Does not return.
// An exited process remains in the zombie state
// until its parent calls wait() to find out it exited.
void
exit(void)
{
  103b80:	55                   	push   %ebp
  103b81:	89 e5                	mov    %esp,%ebp
  103b83:	56                   	push   %esi
  103b84:	53                   	push   %ebx
  struct proc *p;
  int fd;

  if(proc == initproc)
    panic("init exiting");
  103b85:	31 db                	xor    %ebx,%ebx
// Exit the current process.  Does not return.
// An exited process remains in the zombie state
// until its parent calls wait() to find out it exited.
void
exit(void)
{
  103b87:	83 ec 10             	sub    $0x10,%esp
  struct proc *p;
  int fd;

  if(proc == initproc)
  103b8a:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  103b91:	3b 15 c8 95 10 00    	cmp    0x1095c8,%edx
  103b97:	0f 84 14 01 00 00    	je     103cb1 <exit+0x131>
  103b9d:	8d 76 00             	lea    0x0(%esi),%esi
    panic("init exiting");

  // Close all open files.
  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd]){
  103ba0:	8d 73 08             	lea    0x8(%ebx),%esi
  103ba3:	8b 44 b2 08          	mov    0x8(%edx,%esi,4),%eax
  103ba7:	85 c0                	test   %eax,%eax
  103ba9:	74 1d                	je     103bc8 <exit+0x48>
      fileclose(proc->ofile[fd]);
  103bab:	89 04 24             	mov    %eax,(%esp)
  103bae:	e8 5d d5 ff ff       	call   101110 <fileclose>
      proc->ofile[fd] = 0;
  103bb3:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103bb9:	c7 44 b0 08 00 00 00 	movl   $0x0,0x8(%eax,%esi,4)
  103bc0:	00 
  103bc1:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx

  if(proc == initproc)
    panic("init exiting");

  // Close all open files.
  for(fd = 0; fd < NOFILE; fd++){
  103bc8:	83 c3 01             	add    $0x1,%ebx
  103bcb:	83 fb 10             	cmp    $0x10,%ebx
  103bce:	75 d0                	jne    103ba0 <exit+0x20>
      fileclose(proc->ofile[fd]);
      proc->ofile[fd] = 0;
    }
  }

  iput(proc->cwd);
  103bd0:	8b 42 68             	mov    0x68(%edx),%eax
  103bd3:	89 04 24             	mov    %eax,(%esp)
  103bd6:	e8 35 de ff ff       	call   101a10 <iput>
  proc->cwd = 0;
  103bdb:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103be1:	c7 40 68 00 00 00 00 	movl   $0x0,0x68(%eax)

  proc->etime = sys_uptime();
  103be8:	65 8b 1d 04 00 00 00 	mov    %gs:0x4,%ebx
  103bef:	e8 bc 16 00 00       	call   1052b0 <sys_uptime>
  103bf4:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  acquire(&ptable.lock);
  103bfa:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103c01:	e8 ba 06 00 00       	call   1042c0 <acquire>

  // Parent might be sleeping in wait().
  wakeup1(proc->parent);
  103c06:	65 8b 0d 04 00 00 00 	mov    %gs:0x4,%ecx

// Exit the current process.  Does not return.
// An exited process remains in the zombie state
// until its parent calls wait() to find out it exited.
void
exit(void)
  103c0d:	b8 74 ce 10 00       	mov    $0x10ce74,%eax

  proc->etime = sys_uptime();
  acquire(&ptable.lock);

  // Parent might be sleeping in wait().
  wakeup1(proc->parent);
  103c12:	8b 51 14             	mov    0x14(%ecx),%edx
  103c15:	eb 0d                	jmp    103c24 <exit+0xa4>
  103c17:	90                   	nop
static void
wakeup1(void *chan)
{
  struct proc *p;

  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  103c18:	05 90 00 00 00       	add    $0x90,%eax
  103c1d:	3d 74 f2 10 00       	cmp    $0x10f274,%eax
  103c22:	74 1e                	je     103c42 <exit+0xc2>
    if(p->state == SLEEPING && p->chan == chan)
  103c24:	83 78 0c 02          	cmpl   $0x2,0xc(%eax)
  103c28:	75 ee                	jne    103c18 <exit+0x98>
  103c2a:	3b 50 20             	cmp    0x20(%eax),%edx
  103c2d:	75 e9                	jne    103c18 <exit+0x98>
      p->state = RUNNABLE;
  103c2f:	c7 40 0c 03 00 00 00 	movl   $0x3,0xc(%eax)
static void
wakeup1(void *chan)
{
  struct proc *p;

  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  103c36:	05 90 00 00 00       	add    $0x90,%eax
  103c3b:	3d 74 f2 10 00       	cmp    $0x10f274,%eax
  103c40:	75 e2                	jne    103c24 <exit+0xa4>
  wakeup1(proc->parent);

  // Pass abandoned children to init.
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    if(p->parent == proc){
      p->parent = initproc;
  103c42:	8b 1d c8 95 10 00    	mov    0x1095c8,%ebx
  103c48:	ba 74 ce 10 00       	mov    $0x10ce74,%edx
  103c4d:	eb 0f                	jmp    103c5e <exit+0xde>
  103c4f:	90                   	nop

  // Parent might be sleeping in wait().
  wakeup1(proc->parent);

  // Pass abandoned children to init.
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  103c50:	81 c2 90 00 00 00    	add    $0x90,%edx
  103c56:	81 fa 74 f2 10 00    	cmp    $0x10f274,%edx
  103c5c:	74 3a                	je     103c98 <exit+0x118>
    if(p->parent == proc){
  103c5e:	3b 4a 14             	cmp    0x14(%edx),%ecx
  103c61:	75 ed                	jne    103c50 <exit+0xd0>
      p->parent = initproc;
      if(p->state == ZOMBIE)
  103c63:	83 7a 0c 05          	cmpl   $0x5,0xc(%edx)
  wakeup1(proc->parent);

  // Pass abandoned children to init.
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    if(p->parent == proc){
      p->parent = initproc;
  103c67:	89 5a 14             	mov    %ebx,0x14(%edx)
      if(p->state == ZOMBIE)
  103c6a:	75 e4                	jne    103c50 <exit+0xd0>
  103c6c:	b8 74 ce 10 00       	mov    $0x10ce74,%eax
  103c71:	eb 11                	jmp    103c84 <exit+0x104>
  103c73:	90                   	nop
  103c74:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
static void
wakeup1(void *chan)
{
  struct proc *p;

  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  103c78:	05 90 00 00 00       	add    $0x90,%eax
  103c7d:	3d 74 f2 10 00       	cmp    $0x10f274,%eax
  103c82:	74 cc                	je     103c50 <exit+0xd0>
    if(p->state == SLEEPING && p->chan == chan)
  103c84:	83 78 0c 02          	cmpl   $0x2,0xc(%eax)
  103c88:	75 ee                	jne    103c78 <exit+0xf8>
  103c8a:	3b 58 20             	cmp    0x20(%eax),%ebx
  103c8d:	75 e9                	jne    103c78 <exit+0xf8>
      p->state = RUNNABLE;
  103c8f:	c7 40 0c 03 00 00 00 	movl   $0x3,0xc(%eax)
  103c96:	eb e0                	jmp    103c78 <exit+0xf8>
        wakeup1(initproc);
    }
  }

  // Jump into the scheduler, never to return.
  proc->state = ZOMBIE;
  103c98:	c7 41 0c 05 00 00 00 	movl   $0x5,0xc(%ecx)
  103c9f:	90                   	nop
  sched();
  103ca0:	e8 3b f6 ff ff       	call   1032e0 <sched>
  panic("zombie exit");
  103ca5:	c7 04 24 c5 71 10 00 	movl   $0x1071c5,(%esp)
  103cac:	e8 af cd ff ff       	call   100a60 <panic>
{
  struct proc *p;
  int fd;

  if(proc == initproc)
    panic("init exiting");
  103cb1:	c7 04 24 b8 71 10 00 	movl   $0x1071b8,(%esp)
  103cb8:	e8 a3 cd ff ff       	call   100a60 <panic>
  103cbd:	8d 76 00             	lea    0x0(%esi),%esi

00103cc0 <allocproc>:
// Look in the process table for an UNUSED proc.
// If found, change state to EMBRYO and return it.
// Otherwise return 0.
static struct proc*
allocproc(void)
{
  103cc0:	55                   	push   %ebp
  103cc1:	89 e5                	mov    %esp,%ebp
  103cc3:	53                   	push   %ebx
  103cc4:	83 ec 14             	sub    $0x14,%esp
  struct proc *p;
  char *sp;

  acquire(&ptable.lock);
  103cc7:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103cce:	e8 ed 05 00 00       	call   1042c0 <acquire>
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
    if(p->state == UNUSED)
  103cd3:	8b 15 80 ce 10 00    	mov    0x10ce80,%edx
  103cd9:	85 d2                	test   %edx,%edx
  103cdb:	0f 84 cd 00 00 00    	je     103dae <allocproc+0xee>

// Look in the process table for an UNUSED proc.
// If found, change state to EMBRYO and return it.
// Otherwise return 0.
static struct proc*
allocproc(void)
  103ce1:	bb 04 cf 10 00       	mov    $0x10cf04,%ebx
  103ce6:	eb 12                	jmp    103cfa <allocproc+0x3a>
{
  struct proc *p;
  char *sp;

  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
  103ce8:	81 c3 90 00 00 00    	add    $0x90,%ebx
  103cee:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  103cf4:	0f 84 9e 00 00 00    	je     103d98 <allocproc+0xd8>
    if(p->state == UNUSED)
  103cfa:	8b 43 0c             	mov    0xc(%ebx),%eax
  103cfd:	85 c0                	test   %eax,%eax
  103cff:	75 e7                	jne    103ce8 <allocproc+0x28>
      goto found;
  release(&ptable.lock);
  return 0;

found:
  p->state = EMBRYO;
  103d01:	c7 43 0c 01 00 00 00 	movl   $0x1,0xc(%ebx)
  p->pid = nextpid++;
  103d08:	a1 84 88 10 00       	mov    0x108884,%eax
  103d0d:	89 43 10             	mov    %eax,0x10(%ebx)
  103d10:	83 c0 01             	add    $0x1,%eax
  103d13:	a3 84 88 10 00       	mov    %eax,0x108884
  release(&ptable.lock);
  103d18:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103d1f:	e8 4c 05 00 00       	call   104270 <release>

  // Allocate kernel stack if possible.
  if((p->kstack = kalloc()) == 0){
  103d24:	e8 d7 e6 ff ff       	call   102400 <kalloc>
  103d29:	85 c0                	test   %eax,%eax
  103d2b:	89 43 08             	mov    %eax,0x8(%ebx)
  103d2e:	0f 84 84 00 00 00    	je     103db8 <allocproc+0xf8>
    return 0;
  }
  sp = p->kstack + KSTACKSIZE;
  
  // Leave room for trap frame.
  sp -= sizeof *p->tf;
  103d34:	8d 90 b4 0f 00 00    	lea    0xfb4(%eax),%edx
  p->tf = (struct trapframe*)sp;
  103d3a:	89 53 18             	mov    %edx,0x18(%ebx)
  
  // Set up new context to start executing at forkret,
  // which returns to trapret (see below).
  sp -= 4;
  *(uint*)sp = (uint)trapret;
  103d3d:	c7 80 b0 0f 00 00 10 	movl   $0x105510,0xfb0(%eax)
  103d44:	55 10 00 

  sp -= sizeof *p->context;
  p->context = (struct context*)sp;
  103d47:	05 9c 0f 00 00       	add    $0xf9c,%eax
  103d4c:	89 43 1c             	mov    %eax,0x1c(%ebx)
  memset(p->context, 0, sizeof *p->context);
  103d4f:	c7 44 24 08 14 00 00 	movl   $0x14,0x8(%esp)
  103d56:	00 
  103d57:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  103d5e:	00 
  103d5f:	89 04 24             	mov    %eax,(%esp)
  103d62:	e8 f9 05 00 00       	call   104360 <memset>
  p->context->eip = (uint)forkret;
  103d67:	8b 43 1c             	mov    0x1c(%ebx),%eax
  103d6a:	c7 40 10 c0 32 10 00 	movl   $0x1032c0,0x10(%eax)
  p-> ctime = sys_uptime();
  103d71:	e8 3a 15 00 00       	call   1052b0 <sys_uptime>
  p->priority = 1;
  103d76:	c7 83 88 00 00 00 01 	movl   $0x1,0x88(%ebx)
  103d7d:	00 00 00 
  p->runtimeFactor=1;
  103d80:	c7 83 8c 00 00 00 01 	movl   $0x1,0x8c(%ebx)
  103d87:	00 00 00 

  sp -= sizeof *p->context;
  p->context = (struct context*)sp;
  memset(p->context, 0, sizeof *p->context);
  p->context->eip = (uint)forkret;
  p-> ctime = sys_uptime();
  103d8a:	89 43 7c             	mov    %eax,0x7c(%ebx)
  p->priority = 1;
  p->runtimeFactor=1;
  return p;
}
  103d8d:	89 d8                	mov    %ebx,%eax
  103d8f:	83 c4 14             	add    $0x14,%esp
  103d92:	5b                   	pop    %ebx
  103d93:	5d                   	pop    %ebp
  103d94:	c3                   	ret    
  103d95:	8d 76 00             	lea    0x0(%esi),%esi

  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
    if(p->state == UNUSED)
      goto found;
  release(&ptable.lock);
  103d98:	31 db                	xor    %ebx,%ebx
  103d9a:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  103da1:	e8 ca 04 00 00       	call   104270 <release>
  p->context->eip = (uint)forkret;
  p-> ctime = sys_uptime();
  p->priority = 1;
  p->runtimeFactor=1;
  return p;
}
  103da6:	89 d8                	mov    %ebx,%eax
  103da8:	83 c4 14             	add    $0x14,%esp
  103dab:	5b                   	pop    %ebx
  103dac:	5d                   	pop    %ebp
  103dad:	c3                   	ret    
  acquire(&ptable.lock);
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
    if(p->state == UNUSED)
      goto found;
  release(&ptable.lock);
  return 0;
  103dae:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
  103db3:	e9 49 ff ff ff       	jmp    103d01 <allocproc+0x41>
  p->pid = nextpid++;
  release(&ptable.lock);

  // Allocate kernel stack if possible.
  if((p->kstack = kalloc()) == 0){
    p->state = UNUSED;
  103db8:	c7 43 0c 00 00 00 00 	movl   $0x0,0xc(%ebx)
  103dbf:	31 db                	xor    %ebx,%ebx
    return 0;
  103dc1:	eb ca                	jmp    103d8d <allocproc+0xcd>
  103dc3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  103dc9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00103dd0 <fork>:
// Create a new process copying p as the parent.
// Sets up stack to return as if from system call.
// Caller must set state of returned proc to RUNNABLE.
int
fork(void)
{
  103dd0:	55                   	push   %ebp
  103dd1:	89 e5                	mov    %esp,%ebp
  103dd3:	57                   	push   %edi
  103dd4:	56                   	push   %esi
  int i, pid;
  struct proc *np;

  // Allocate process.
  if((np = allocproc()) == 0)
  103dd5:	be ff ff ff ff       	mov    $0xffffffff,%esi
// Create a new process copying p as the parent.
// Sets up stack to return as if from system call.
// Caller must set state of returned proc to RUNNABLE.
int
fork(void)
{
  103dda:	53                   	push   %ebx
  103ddb:	83 ec 1c             	sub    $0x1c,%esp
  int i, pid;
  struct proc *np;

  // Allocate process.
  if((np = allocproc()) == 0)
  103dde:	e8 dd fe ff ff       	call   103cc0 <allocproc>
  103de3:	85 c0                	test   %eax,%eax
  103de5:	89 c3                	mov    %eax,%ebx
  103de7:	0f 84 be 00 00 00    	je     103eab <fork+0xdb>
    return -1;

  // Copy process state from p.
  if(!(np->pgdir = copyuvm(proc->pgdir, proc->sz))){
  103ded:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103df3:	8b 10                	mov    (%eax),%edx
  103df5:	89 54 24 04          	mov    %edx,0x4(%esp)
  103df9:	8b 40 04             	mov    0x4(%eax),%eax
  103dfc:	89 04 24             	mov    %eax,(%esp)
  103dff:	e8 2c 2a 00 00       	call   106830 <copyuvm>
  103e04:	85 c0                	test   %eax,%eax
  103e06:	89 43 04             	mov    %eax,0x4(%ebx)
  103e09:	0f 84 a6 00 00 00    	je     103eb5 <fork+0xe5>
    kfree(np->kstack);
    np->kstack = 0;
    np->state = UNUSED;
    return -1;
  }
  np->sz = proc->sz;
  103e0f:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  np->parent = proc;
  *np->tf = *proc->tf;
  103e15:	b9 13 00 00 00       	mov    $0x13,%ecx
    kfree(np->kstack);
    np->kstack = 0;
    np->state = UNUSED;
    return -1;
  }
  np->sz = proc->sz;
  103e1a:	8b 00                	mov    (%eax),%eax
  103e1c:	89 03                	mov    %eax,(%ebx)
  np->parent = proc;
  103e1e:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103e24:	89 43 14             	mov    %eax,0x14(%ebx)
  *np->tf = *proc->tf;
  103e27:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  103e2e:	8b 43 18             	mov    0x18(%ebx),%eax
  103e31:	8b 72 18             	mov    0x18(%edx),%esi
  103e34:	89 c7                	mov    %eax,%edi
  103e36:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)

  // Clear %eax so that fork returns 0 in the child.
  np->tf->eax = 0;
  103e38:	31 f6                	xor    %esi,%esi
  103e3a:	8b 43 18             	mov    0x18(%ebx),%eax
  103e3d:	c7 40 1c 00 00 00 00 	movl   $0x0,0x1c(%eax)
  103e44:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  103e4b:	90                   	nop
  103e4c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

  for(i = 0; i < NOFILE; i++)
    if(proc->ofile[i])
  103e50:	8b 44 b2 28          	mov    0x28(%edx,%esi,4),%eax
  103e54:	85 c0                	test   %eax,%eax
  103e56:	74 13                	je     103e6b <fork+0x9b>
      np->ofile[i] = filedup(proc->ofile[i]);
  103e58:	89 04 24             	mov    %eax,(%esp)
  103e5b:	e8 e0 d1 ff ff       	call   101040 <filedup>
  103e60:	89 44 b3 28          	mov    %eax,0x28(%ebx,%esi,4)
  103e64:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  *np->tf = *proc->tf;

  // Clear %eax so that fork returns 0 in the child.
  np->tf->eax = 0;

  for(i = 0; i < NOFILE; i++)
  103e6b:	83 c6 01             	add    $0x1,%esi
  103e6e:	83 fe 10             	cmp    $0x10,%esi
  103e71:	75 dd                	jne    103e50 <fork+0x80>
    if(proc->ofile[i])
      np->ofile[i] = filedup(proc->ofile[i]);
  np->cwd = idup(proc->cwd);
  103e73:	8b 42 68             	mov    0x68(%edx),%eax
  103e76:	89 04 24             	mov    %eax,(%esp)
  103e79:	e8 c2 d3 ff ff       	call   101240 <idup>
 
  pid = np->pid;
  103e7e:	8b 73 10             	mov    0x10(%ebx),%esi
  np->state = RUNNABLE;
  103e81:	c7 43 0c 03 00 00 00 	movl   $0x3,0xc(%ebx)
  np->tf->eax = 0;

  for(i = 0; i < NOFILE; i++)
    if(proc->ofile[i])
      np->ofile[i] = filedup(proc->ofile[i]);
  np->cwd = idup(proc->cwd);
  103e88:	89 43 68             	mov    %eax,0x68(%ebx)
 
  pid = np->pid;
  np->state = RUNNABLE;
//   np->ctime = sys_uptime();
  safestrcpy(np->name, proc->name, sizeof(proc->name));
  103e8b:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103e91:	83 c3 6c             	add    $0x6c,%ebx
  103e94:	c7 44 24 08 10 00 00 	movl   $0x10,0x8(%esp)
  103e9b:	00 
  103e9c:	89 1c 24             	mov    %ebx,(%esp)
  103e9f:	83 c0 6c             	add    $0x6c,%eax
  103ea2:	89 44 24 04          	mov    %eax,0x4(%esp)
  103ea6:	e8 55 06 00 00       	call   104500 <safestrcpy>
  return pid;
}
  103eab:	83 c4 1c             	add    $0x1c,%esp
  103eae:	89 f0                	mov    %esi,%eax
  103eb0:	5b                   	pop    %ebx
  103eb1:	5e                   	pop    %esi
  103eb2:	5f                   	pop    %edi
  103eb3:	5d                   	pop    %ebp
  103eb4:	c3                   	ret    
  if((np = allocproc()) == 0)
    return -1;

  // Copy process state from p.
  if(!(np->pgdir = copyuvm(proc->pgdir, proc->sz))){
    kfree(np->kstack);
  103eb5:	8b 43 08             	mov    0x8(%ebx),%eax
  103eb8:	89 04 24             	mov    %eax,(%esp)
  103ebb:	e8 80 e5 ff ff       	call   102440 <kfree>
    np->kstack = 0;
  103ec0:	c7 43 08 00 00 00 00 	movl   $0x0,0x8(%ebx)
    np->state = UNUSED;
  103ec7:	c7 43 0c 00 00 00 00 	movl   $0x0,0xc(%ebx)
    return -1;
  103ece:	eb db                	jmp    103eab <fork+0xdb>

00103ed0 <growproc>:

// Grow current process's memory by n bytes.
// Return 0 on success, -1 on failure.
int
growproc(int n)
{
  103ed0:	55                   	push   %ebp
  103ed1:	89 e5                	mov    %esp,%ebp
  103ed3:	83 ec 18             	sub    $0x18,%esp
  uint sz = proc->sz;
  103ed6:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx

// Grow current process's memory by n bytes.
// Return 0 on success, -1 on failure.
int
growproc(int n)
{
  103edd:	8b 4d 08             	mov    0x8(%ebp),%ecx
  uint sz = proc->sz;
  103ee0:	8b 02                	mov    (%edx),%eax
  if(n > 0){
  103ee2:	83 f9 00             	cmp    $0x0,%ecx
  103ee5:	7f 19                	jg     103f00 <growproc+0x30>
    if(!(sz = allocuvm(proc->pgdir, sz, sz + n)))
      return -1;
  } else if(n < 0){
  103ee7:	75 39                	jne    103f22 <growproc+0x52>
    if(!(sz = deallocuvm(proc->pgdir, sz, sz + n)))
      return -1;
  }
  proc->sz = sz;
  103ee9:	89 02                	mov    %eax,(%edx)
  switchuvm(proc);
  103eeb:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  103ef1:	89 04 24             	mov    %eax,(%esp)
  103ef4:	e8 87 2b 00 00       	call   106a80 <switchuvm>
  103ef9:	31 c0                	xor    %eax,%eax
  return 0;
}
  103efb:	c9                   	leave  
  103efc:	c3                   	ret    
  103efd:	8d 76 00             	lea    0x0(%esi),%esi
int
growproc(int n)
{
  uint sz = proc->sz;
  if(n > 0){
    if(!(sz = allocuvm(proc->pgdir, sz, sz + n)))
  103f00:	01 c1                	add    %eax,%ecx
  103f02:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  103f06:	89 44 24 04          	mov    %eax,0x4(%esp)
  103f0a:	8b 42 04             	mov    0x4(%edx),%eax
  103f0d:	89 04 24             	mov    %eax,(%esp)
  103f10:	e8 db 29 00 00       	call   1068f0 <allocuvm>
  103f15:	85 c0                	test   %eax,%eax
  103f17:	74 27                	je     103f40 <growproc+0x70>
      return -1;
  } else if(n < 0){
    if(!(sz = deallocuvm(proc->pgdir, sz, sz + n)))
  103f19:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  103f20:	eb c7                	jmp    103ee9 <growproc+0x19>
  103f22:	01 c1                	add    %eax,%ecx
  103f24:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  103f28:	89 44 24 04          	mov    %eax,0x4(%esp)
  103f2c:	8b 42 04             	mov    0x4(%edx),%eax
  103f2f:	89 04 24             	mov    %eax,(%esp)
  103f32:	e8 d9 27 00 00       	call   106710 <deallocuvm>
  103f37:	85 c0                	test   %eax,%eax
  103f39:	75 de                	jne    103f19 <growproc+0x49>
  103f3b:	90                   	nop
  103f3c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
      return -1;
  }
  proc->sz = sz;
  switchuvm(proc);
  return 0;
  103f40:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  103f45:	c9                   	leave  
  103f46:	c3                   	ret    
  103f47:	89 f6                	mov    %esi,%esi
  103f49:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00103f50 <userinit>:
}

// Set up first user process.
void
userinit(void)
{
  103f50:	55                   	push   %ebp
  103f51:	89 e5                	mov    %esp,%ebp
  103f53:	53                   	push   %ebx
  103f54:	83 ec 14             	sub    $0x14,%esp
  struct proc *p;
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  103f57:	e8 64 fd ff ff       	call   103cc0 <allocproc>
  103f5c:	89 c3                	mov    %eax,%ebx
  initproc = p;
  103f5e:	a3 c8 95 10 00       	mov    %eax,0x1095c8
  if(!(p->pgdir = setupkvm()))
  103f63:	e8 c8 26 00 00       	call   106630 <setupkvm>
  103f68:	85 c0                	test   %eax,%eax
  103f6a:	89 43 04             	mov    %eax,0x4(%ebx)
  103f6d:	0f 84 be 00 00 00    	je     104031 <userinit+0xe1>
    panic("userinit: out of memory?");
  inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
  103f73:	89 04 24             	mov    %eax,(%esp)
  103f76:	c7 44 24 08 2c 00 00 	movl   $0x2c,0x8(%esp)
  103f7d:	00 
  103f7e:	c7 44 24 04 88 8c 10 	movl   $0x108c88,0x4(%esp)
  103f85:	00 
  103f86:	e8 15 26 00 00       	call   1065a0 <inituvm>
  p->sz = PGSIZE;
  103f8b:	c7 03 00 10 00 00    	movl   $0x1000,(%ebx)
  memset(p->tf, 0, sizeof(*p->tf));
  103f91:	c7 44 24 08 4c 00 00 	movl   $0x4c,0x8(%esp)
  103f98:	00 
  103f99:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  103fa0:	00 
  103fa1:	8b 43 18             	mov    0x18(%ebx),%eax
  103fa4:	89 04 24             	mov    %eax,(%esp)
  103fa7:	e8 b4 03 00 00       	call   104360 <memset>
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  103fac:	8b 43 18             	mov    0x18(%ebx),%eax
  103faf:	66 c7 40 3c 23 00    	movw   $0x23,0x3c(%eax)
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  103fb5:	8b 43 18             	mov    0x18(%ebx),%eax
  103fb8:	66 c7 40 2c 2b 00    	movw   $0x2b,0x2c(%eax)
  p->tf->es = p->tf->ds;
  103fbe:	8b 43 18             	mov    0x18(%ebx),%eax
  103fc1:	0f b7 50 2c          	movzwl 0x2c(%eax),%edx
  103fc5:	66 89 50 28          	mov    %dx,0x28(%eax)
  p->tf->ss = p->tf->ds;
  103fc9:	8b 43 18             	mov    0x18(%ebx),%eax
  103fcc:	0f b7 50 2c          	movzwl 0x2c(%eax),%edx
  103fd0:	66 89 50 48          	mov    %dx,0x48(%eax)
  p->tf->eflags = FL_IF;
  103fd4:	8b 43 18             	mov    0x18(%ebx),%eax
  103fd7:	c7 40 40 00 02 00 00 	movl   $0x200,0x40(%eax)
  p->tf->esp = PGSIZE;
  103fde:	8b 43 18             	mov    0x18(%ebx),%eax
  103fe1:	c7 40 44 00 10 00 00 	movl   $0x1000,0x44(%eax)
  p->tf->eip = 0;  // beginning of initcode.S
  103fe8:	8b 43 18             	mov    0x18(%ebx),%eax
  103feb:	c7 40 38 00 00 00 00 	movl   $0x0,0x38(%eax)

  safestrcpy(p->name, "initcode", sizeof(p->name));
  103ff2:	8d 43 6c             	lea    0x6c(%ebx),%eax
  103ff5:	c7 44 24 08 10 00 00 	movl   $0x10,0x8(%esp)
  103ffc:	00 
  103ffd:	c7 44 24 04 ea 71 10 	movl   $0x1071ea,0x4(%esp)
  104004:	00 
  104005:	89 04 24             	mov    %eax,(%esp)
  104008:	e8 f3 04 00 00       	call   104500 <safestrcpy>
  p->cwd = namei("/");
  10400d:	c7 04 24 f3 71 10 00 	movl   $0x1071f3,(%esp)
  104014:	e8 c7 df ff ff       	call   101fe0 <namei>

  p->state = RUNNABLE;
  104019:	c7 43 0c 03 00 00 00 	movl   $0x3,0xc(%ebx)
  p->tf->eflags = FL_IF;
  p->tf->esp = PGSIZE;
  p->tf->eip = 0;  // beginning of initcode.S

  safestrcpy(p->name, "initcode", sizeof(p->name));
  p->cwd = namei("/");
  104020:	89 43 68             	mov    %eax,0x68(%ebx)

  p->state = RUNNABLE;
  p->ctime = sys_uptime();
  104023:	e8 88 12 00 00       	call   1052b0 <sys_uptime>
  104028:	89 43 7c             	mov    %eax,0x7c(%ebx)
  //initializing creation time
  
}
  10402b:	83 c4 14             	add    $0x14,%esp
  10402e:	5b                   	pop    %ebx
  10402f:	5d                   	pop    %ebp
  104030:	c3                   	ret    
  extern char _binary_initcode_start[], _binary_initcode_size[];
  
  p = allocproc();
  initproc = p;
  if(!(p->pgdir = setupkvm()))
    panic("userinit: out of memory?");
  104031:	c7 04 24 d1 71 10 00 	movl   $0x1071d1,(%esp)
  104038:	e8 23 ca ff ff       	call   100a60 <panic>
  10403d:	8d 76 00             	lea    0x0(%esi),%esi

00104040 <procdump>:
// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
  104040:	55                   	push   %ebp
  104041:	89 e5                	mov    %esp,%ebp
  104043:	57                   	push   %edi
  104044:	56                   	push   %esi
  104045:	53                   	push   %ebx

// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
  104046:	bb 74 ce 10 00       	mov    $0x10ce74,%ebx
{
  10404b:	83 ec 4c             	sub    $0x4c,%esp
      state = states[p->state];
    else
      state = "???";
    cprintf("%d %s %s", p->pid, state, p->name);
    if(p->state == SLEEPING){
      getcallerpcs((uint*)p->context->ebp+2, pc);
  10404e:	8d 7d c0             	lea    -0x40(%ebp),%edi
  104051:	eb 4e                	jmp    1040a1 <procdump+0x61>
  104053:	90                   	nop
  104054:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  uint pc[10];
  
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
    if(p->state == UNUSED)
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
  104058:	8b 04 85 34 72 10 00 	mov    0x107234(,%eax,4),%eax
  10405f:	85 c0                	test   %eax,%eax
  104061:	74 4a                	je     1040ad <procdump+0x6d>
      state = states[p->state];
    else
      state = "???";
    cprintf("%d %s %s", p->pid, state, p->name);
  104063:	8b 53 10             	mov    0x10(%ebx),%edx
  104066:	8d 4b 6c             	lea    0x6c(%ebx),%ecx
  104069:	89 4c 24 0c          	mov    %ecx,0xc(%esp)
  10406d:	89 44 24 08          	mov    %eax,0x8(%esp)
  104071:	c7 04 24 f9 71 10 00 	movl   $0x1071f9,(%esp)
  104078:	89 54 24 04          	mov    %edx,0x4(%esp)
  10407c:	e8 3f c4 ff ff       	call   1004c0 <cprintf>
    if(p->state == SLEEPING){
  104081:	83 7b 0c 02          	cmpl   $0x2,0xc(%ebx)
  104085:	74 31                	je     1040b8 <procdump+0x78>
      getcallerpcs((uint*)p->context->ebp+2, pc);
      for(i=0; i<10 && pc[i] != 0; i++)
        cprintf(" %p", pc[i]);
    }
    cprintf("\n");
  104087:	c7 04 24 d6 70 10 00 	movl   $0x1070d6,(%esp)
  10408e:	e8 2d c4 ff ff       	call   1004c0 <cprintf>
  int i;
  struct proc *p;
  char *state;
  uint pc[10];
  
  for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
  104093:	81 c3 90 00 00 00    	add    $0x90,%ebx
  104099:	81 fb 74 f2 10 00    	cmp    $0x10f274,%ebx
  10409f:	74 57                	je     1040f8 <procdump+0xb8>
    if(p->state == UNUSED)
  1040a1:	8b 43 0c             	mov    0xc(%ebx),%eax
  1040a4:	85 c0                	test   %eax,%eax
  1040a6:	74 eb                	je     104093 <procdump+0x53>
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
  1040a8:	83 f8 05             	cmp    $0x5,%eax
  1040ab:	76 ab                	jbe    104058 <procdump+0x18>
  1040ad:	b8 f5 71 10 00       	mov    $0x1071f5,%eax
  1040b2:	eb af                	jmp    104063 <procdump+0x23>
  1040b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
      state = states[p->state];
    else
      state = "???";
    cprintf("%d %s %s", p->pid, state, p->name);
    if(p->state == SLEEPING){
      getcallerpcs((uint*)p->context->ebp+2, pc);
  1040b8:	8b 43 1c             	mov    0x1c(%ebx),%eax
  1040bb:	31 f6                	xor    %esi,%esi
  1040bd:	89 7c 24 04          	mov    %edi,0x4(%esp)
  1040c1:	8b 40 0c             	mov    0xc(%eax),%eax
  1040c4:	83 c0 08             	add    $0x8,%eax
  1040c7:	89 04 24             	mov    %eax,(%esp)
  1040ca:	e8 81 00 00 00       	call   104150 <getcallerpcs>
  1040cf:	90                   	nop
      for(i=0; i<10 && pc[i] != 0; i++)
  1040d0:	8b 04 b7             	mov    (%edi,%esi,4),%eax
  1040d3:	85 c0                	test   %eax,%eax
  1040d5:	74 b0                	je     104087 <procdump+0x47>
  1040d7:	83 c6 01             	add    $0x1,%esi
        cprintf(" %p", pc[i]);
  1040da:	89 44 24 04          	mov    %eax,0x4(%esp)
  1040de:	c7 04 24 aa 6c 10 00 	movl   $0x106caa,(%esp)
  1040e5:	e8 d6 c3 ff ff       	call   1004c0 <cprintf>
    else
      state = "???";
    cprintf("%d %s %s", p->pid, state, p->name);
    if(p->state == SLEEPING){
      getcallerpcs((uint*)p->context->ebp+2, pc);
      for(i=0; i<10 && pc[i] != 0; i++)
  1040ea:	83 fe 0a             	cmp    $0xa,%esi
  1040ed:	75 e1                	jne    1040d0 <procdump+0x90>
  1040ef:	eb 96                	jmp    104087 <procdump+0x47>
  1040f1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
        cprintf(" %p", pc[i]);
    }
    cprintf("\n");
  }
}
  1040f8:	83 c4 4c             	add    $0x4c,%esp
  1040fb:	5b                   	pop    %ebx
  1040fc:	5e                   	pop    %esi
  1040fd:	5f                   	pop    %edi
  1040fe:	5d                   	pop    %ebp
  1040ff:	90                   	nop
  104100:	c3                   	ret    
  104101:	eb 0d                	jmp    104110 <pinit>
  104103:	90                   	nop
  104104:	90                   	nop
  104105:	90                   	nop
  104106:	90                   	nop
  104107:	90                   	nop
  104108:	90                   	nop
  104109:	90                   	nop
  10410a:	90                   	nop
  10410b:	90                   	nop
  10410c:	90                   	nop
  10410d:	90                   	nop
  10410e:	90                   	nop
  10410f:	90                   	nop

00104110 <pinit>:

static void wakeup1(void *chan);

void
pinit(void)
{
  104110:	55                   	push   %ebp
  104111:	89 e5                	mov    %esp,%ebp
  104113:	83 ec 18             	sub    $0x18,%esp
  initlock(&ptable.lock, "ptable");
  104116:	c7 44 24 04 02 72 10 	movl   $0x107202,0x4(%esp)
  10411d:	00 
  10411e:	c7 04 24 40 ce 10 00 	movl   $0x10ce40,(%esp)
  104125:	e8 06 00 00 00       	call   104130 <initlock>
}
  10412a:	c9                   	leave  
  10412b:	c3                   	ret    
  10412c:	90                   	nop
  10412d:	90                   	nop
  10412e:	90                   	nop
  10412f:	90                   	nop

00104130 <initlock>:
#include "proc.h"
#include "spinlock.h"

void
initlock(struct spinlock *lk, char *name)
{
  104130:	55                   	push   %ebp
  104131:	89 e5                	mov    %esp,%ebp
  104133:	8b 45 08             	mov    0x8(%ebp),%eax
  lk->name = name;
  104136:	8b 55 0c             	mov    0xc(%ebp),%edx
  lk->locked = 0;
  104139:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
#include "spinlock.h"

void
initlock(struct spinlock *lk, char *name)
{
  lk->name = name;
  10413f:	89 50 04             	mov    %edx,0x4(%eax)
  lk->locked = 0;
  lk->cpu = 0;
  104142:	c7 40 08 00 00 00 00 	movl   $0x0,0x8(%eax)
}
  104149:	5d                   	pop    %ebp
  10414a:	c3                   	ret    
  10414b:	90                   	nop
  10414c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00104150 <getcallerpcs>:
}

// Record the current call stack in pcs[] by following the %ebp chain.
void
getcallerpcs(void *v, uint pcs[])
{
  104150:	55                   	push   %ebp
  uint *ebp;
  int i;
  
  ebp = (uint*)v - 2;
  104151:	31 c0                	xor    %eax,%eax
}

// Record the current call stack in pcs[] by following the %ebp chain.
void
getcallerpcs(void *v, uint pcs[])
{
  104153:	89 e5                	mov    %esp,%ebp
  104155:	53                   	push   %ebx
  uint *ebp;
  int i;
  
  ebp = (uint*)v - 2;
  104156:	8b 55 08             	mov    0x8(%ebp),%edx
}

// Record the current call stack in pcs[] by following the %ebp chain.
void
getcallerpcs(void *v, uint pcs[])
{
  104159:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  uint *ebp;
  int i;
  
  ebp = (uint*)v - 2;
  10415c:	83 ea 08             	sub    $0x8,%edx
  10415f:	90                   	nop
  for(i = 0; i < 10; i++){
    if(ebp == 0 || ebp < (uint *) 0x100000 || ebp == (uint*)0xffffffff)
  104160:	8d 8a 00 00 f0 ff    	lea    -0x100000(%edx),%ecx
  104166:	81 f9 fe ff ef ff    	cmp    $0xffeffffe,%ecx
  10416c:	77 1a                	ja     104188 <getcallerpcs+0x38>
      break;
    pcs[i] = ebp[1];     // saved %eip
  10416e:	8b 4a 04             	mov    0x4(%edx),%ecx
  104171:	89 0c 83             	mov    %ecx,(%ebx,%eax,4)
{
  uint *ebp;
  int i;
  
  ebp = (uint*)v - 2;
  for(i = 0; i < 10; i++){
  104174:	83 c0 01             	add    $0x1,%eax
    if(ebp == 0 || ebp < (uint *) 0x100000 || ebp == (uint*)0xffffffff)
      break;
    pcs[i] = ebp[1];     // saved %eip
    ebp = (uint*)ebp[0]; // saved %ebp
  104177:	8b 12                	mov    (%edx),%edx
{
  uint *ebp;
  int i;
  
  ebp = (uint*)v - 2;
  for(i = 0; i < 10; i++){
  104179:	83 f8 0a             	cmp    $0xa,%eax
  10417c:	75 e2                	jne    104160 <getcallerpcs+0x10>
    pcs[i] = ebp[1];     // saved %eip
    ebp = (uint*)ebp[0]; // saved %ebp
  }
  for(; i < 10; i++)
    pcs[i] = 0;
}
  10417e:	5b                   	pop    %ebx
  10417f:	5d                   	pop    %ebp
  104180:	c3                   	ret    
  104181:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    if(ebp == 0 || ebp < (uint *) 0x100000 || ebp == (uint*)0xffffffff)
      break;
    pcs[i] = ebp[1];     // saved %eip
    ebp = (uint*)ebp[0]; // saved %ebp
  }
  for(; i < 10; i++)
  104188:	83 f8 09             	cmp    $0x9,%eax
  10418b:	7f f1                	jg     10417e <getcallerpcs+0x2e>
  ebp = (uint*)v - 2;
  for(i = 0; i < 10; i++){
    if(ebp == 0 || ebp < (uint *) 0x100000 || ebp == (uint*)0xffffffff)
      break;
    pcs[i] = ebp[1];     // saved %eip
    ebp = (uint*)ebp[0]; // saved %ebp
  10418d:	8d 14 83             	lea    (%ebx,%eax,4),%edx
  }
  for(; i < 10; i++)
  104190:	83 c0 01             	add    $0x1,%eax
    pcs[i] = 0;
  104193:	c7 02 00 00 00 00    	movl   $0x0,(%edx)
    if(ebp == 0 || ebp < (uint *) 0x100000 || ebp == (uint*)0xffffffff)
      break;
    pcs[i] = ebp[1];     // saved %eip
    ebp = (uint*)ebp[0]; // saved %ebp
  }
  for(; i < 10; i++)
  104199:	83 c2 04             	add    $0x4,%edx
  10419c:	83 f8 0a             	cmp    $0xa,%eax
  10419f:	75 ef                	jne    104190 <getcallerpcs+0x40>
    pcs[i] = 0;
}
  1041a1:	5b                   	pop    %ebx
  1041a2:	5d                   	pop    %ebp
  1041a3:	c3                   	ret    
  1041a4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  1041aa:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

001041b0 <holding>:

// Check whether this cpu is holding the lock.
int
holding(struct spinlock *lock)
{
  1041b0:	55                   	push   %ebp
  return lock->locked && lock->cpu == cpu;
  1041b1:	31 c0                	xor    %eax,%eax
}

// Check whether this cpu is holding the lock.
int
holding(struct spinlock *lock)
{
  1041b3:	89 e5                	mov    %esp,%ebp
  1041b5:	8b 55 08             	mov    0x8(%ebp),%edx
  return lock->locked && lock->cpu == cpu;
  1041b8:	8b 0a                	mov    (%edx),%ecx
  1041ba:	85 c9                	test   %ecx,%ecx
  1041bc:	74 10                	je     1041ce <holding+0x1e>
  1041be:	8b 42 08             	mov    0x8(%edx),%eax
  1041c1:	65 3b 05 00 00 00 00 	cmp    %gs:0x0,%eax
  1041c8:	0f 94 c0             	sete   %al
  1041cb:	0f b6 c0             	movzbl %al,%eax
}
  1041ce:	5d                   	pop    %ebp
  1041cf:	c3                   	ret    

001041d0 <pushcli>:
// it takes two popcli to undo two pushcli.  Also, if interrupts
// are off, then pushcli, popcli leaves them off.

void
pushcli(void)
{
  1041d0:	55                   	push   %ebp
  1041d1:	89 e5                	mov    %esp,%ebp
  1041d3:	53                   	push   %ebx

static inline uint
readeflags(void)
{
  uint eflags;
  asm volatile("pushfl; popl %0" : "=r" (eflags));
  1041d4:	9c                   	pushf  
  1041d5:	5b                   	pop    %ebx
}

static inline void
cli(void)
{
  asm volatile("cli");
  1041d6:	fa                   	cli    
  int eflags;
  
  eflags = readeflags();
  cli();
  if(cpu->ncli++ == 0)
  1041d7:	65 8b 15 00 00 00 00 	mov    %gs:0x0,%edx
  1041de:	8b 82 ac 00 00 00    	mov    0xac(%edx),%eax
  1041e4:	8d 48 01             	lea    0x1(%eax),%ecx
  1041e7:	85 c0                	test   %eax,%eax
  1041e9:	89 8a ac 00 00 00    	mov    %ecx,0xac(%edx)
  1041ef:	75 12                	jne    104203 <pushcli+0x33>
    cpu->intena = eflags & FL_IF;
  1041f1:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  1041f7:	81 e3 00 02 00 00    	and    $0x200,%ebx
  1041fd:	89 98 b0 00 00 00    	mov    %ebx,0xb0(%eax)
}
  104203:	5b                   	pop    %ebx
  104204:	5d                   	pop    %ebp
  104205:	c3                   	ret    
  104206:	8d 76 00             	lea    0x0(%esi),%esi
  104209:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104210 <popcli>:

void
popcli(void)
{
  104210:	55                   	push   %ebp
  104211:	89 e5                	mov    %esp,%ebp
  104213:	83 ec 18             	sub    $0x18,%esp

static inline uint
readeflags(void)
{
  uint eflags;
  asm volatile("pushfl; popl %0" : "=r" (eflags));
  104216:	9c                   	pushf  
  104217:	58                   	pop    %eax
  if(readeflags()&FL_IF)
  104218:	f6 c4 02             	test   $0x2,%ah
  10421b:	75 43                	jne    104260 <popcli+0x50>
    panic("popcli - interruptible");
  if(--cpu->ncli < 0)
  10421d:	65 8b 15 00 00 00 00 	mov    %gs:0x0,%edx
  104224:	8b 82 ac 00 00 00    	mov    0xac(%edx),%eax
  10422a:	83 e8 01             	sub    $0x1,%eax
  10422d:	85 c0                	test   %eax,%eax
  10422f:	89 82 ac 00 00 00    	mov    %eax,0xac(%edx)
  104235:	78 1d                	js     104254 <popcli+0x44>
    panic("popcli");
  if(cpu->ncli == 0 && cpu->intena)
  104237:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  10423d:	8b 90 ac 00 00 00    	mov    0xac(%eax),%edx
  104243:	85 d2                	test   %edx,%edx
  104245:	75 0b                	jne    104252 <popcli+0x42>
  104247:	8b 80 b0 00 00 00    	mov    0xb0(%eax),%eax
  10424d:	85 c0                	test   %eax,%eax
  10424f:	74 01                	je     104252 <popcli+0x42>
}

static inline void
sti(void)
{
  asm volatile("sti");
  104251:	fb                   	sti    
    sti();
}
  104252:	c9                   	leave  
  104253:	c3                   	ret    
popcli(void)
{
  if(readeflags()&FL_IF)
    panic("popcli - interruptible");
  if(--cpu->ncli < 0)
    panic("popcli");
  104254:	c7 04 24 6b 72 10 00 	movl   $0x10726b,(%esp)
  10425b:	e8 00 c8 ff ff       	call   100a60 <panic>

void
popcli(void)
{
  if(readeflags()&FL_IF)
    panic("popcli - interruptible");
  104260:	c7 04 24 54 72 10 00 	movl   $0x107254,(%esp)
  104267:	e8 f4 c7 ff ff       	call   100a60 <panic>
  10426c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00104270 <release>:
}

// Release the lock.
void
release(struct spinlock *lk)
{
  104270:	55                   	push   %ebp
  104271:	89 e5                	mov    %esp,%ebp
  104273:	83 ec 18             	sub    $0x18,%esp
  104276:	8b 55 08             	mov    0x8(%ebp),%edx

// Check whether this cpu is holding the lock.
int
holding(struct spinlock *lock)
{
  return lock->locked && lock->cpu == cpu;
  104279:	8b 0a                	mov    (%edx),%ecx
  10427b:	85 c9                	test   %ecx,%ecx
  10427d:	74 0c                	je     10428b <release+0x1b>
  10427f:	8b 42 08             	mov    0x8(%edx),%eax
  104282:	65 3b 05 00 00 00 00 	cmp    %gs:0x0,%eax
  104289:	74 0d                	je     104298 <release+0x28>
// Release the lock.
void
release(struct spinlock *lk)
{
  if(!holding(lk))
    panic("release");
  10428b:	c7 04 24 72 72 10 00 	movl   $0x107272,(%esp)
  104292:	e8 c9 c7 ff ff       	call   100a60 <panic>
  104297:	90                   	nop

  lk->pcs[0] = 0;
  104298:	c7 42 0c 00 00 00 00 	movl   $0x0,0xc(%edx)
xchg(volatile uint *addr, uint newval)
{
  uint result;
  
  // The + in "+m" denotes a read-modify-write operand.
  asm volatile("lock; xchgl %0, %1" :
  10429f:	31 c0                	xor    %eax,%eax
  lk->cpu = 0;
  1042a1:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)
  1042a8:	f0 87 02             	lock xchg %eax,(%edx)
  // The xchg being asm volatile ensures gcc emits it after
  // the above assignments (and after the critical section).
  xchg(&lk->locked, 0);

  popcli();
}
  1042ab:	c9                   	leave  
  // after a store. So lock->locked = 0 would work here.
  // The xchg being asm volatile ensures gcc emits it after
  // the above assignments (and after the critical section).
  xchg(&lk->locked, 0);

  popcli();
  1042ac:	e9 5f ff ff ff       	jmp    104210 <popcli>
  1042b1:	eb 0d                	jmp    1042c0 <acquire>
  1042b3:	90                   	nop
  1042b4:	90                   	nop
  1042b5:	90                   	nop
  1042b6:	90                   	nop
  1042b7:	90                   	nop
  1042b8:	90                   	nop
  1042b9:	90                   	nop
  1042ba:	90                   	nop
  1042bb:	90                   	nop
  1042bc:	90                   	nop
  1042bd:	90                   	nop
  1042be:	90                   	nop
  1042bf:	90                   	nop

001042c0 <acquire>:
// Loops (spins) until the lock is acquired.
// Holding a lock for a long time may cause
// other CPUs to waste time spinning to acquire it.
void
acquire(struct spinlock *lk)
{
  1042c0:	55                   	push   %ebp
  1042c1:	89 e5                	mov    %esp,%ebp
  1042c3:	53                   	push   %ebx
  1042c4:	83 ec 14             	sub    $0x14,%esp

static inline uint
readeflags(void)
{
  uint eflags;
  asm volatile("pushfl; popl %0" : "=r" (eflags));
  1042c7:	9c                   	pushf  
  1042c8:	5b                   	pop    %ebx
}

static inline void
cli(void)
{
  asm volatile("cli");
  1042c9:	fa                   	cli    
{
  int eflags;
  
  eflags = readeflags();
  cli();
  if(cpu->ncli++ == 0)
  1042ca:	65 8b 15 00 00 00 00 	mov    %gs:0x0,%edx
  1042d1:	8b 82 ac 00 00 00    	mov    0xac(%edx),%eax
  1042d7:	8d 48 01             	lea    0x1(%eax),%ecx
  1042da:	85 c0                	test   %eax,%eax
  1042dc:	89 8a ac 00 00 00    	mov    %ecx,0xac(%edx)
  1042e2:	75 12                	jne    1042f6 <acquire+0x36>
    cpu->intena = eflags & FL_IF;
  1042e4:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  1042ea:	81 e3 00 02 00 00    	and    $0x200,%ebx
  1042f0:	89 98 b0 00 00 00    	mov    %ebx,0xb0(%eax)
// other CPUs to waste time spinning to acquire it.
void
acquire(struct spinlock *lk)
{
  pushcli();
  if(holding(lk))
  1042f6:	8b 55 08             	mov    0x8(%ebp),%edx

// Check whether this cpu is holding the lock.
int
holding(struct spinlock *lock)
{
  return lock->locked && lock->cpu == cpu;
  1042f9:	8b 1a                	mov    (%edx),%ebx
  1042fb:	85 db                	test   %ebx,%ebx
  1042fd:	74 0c                	je     10430b <acquire+0x4b>
  1042ff:	8b 42 08             	mov    0x8(%edx),%eax
  104302:	65 3b 05 00 00 00 00 	cmp    %gs:0x0,%eax
  104309:	74 45                	je     104350 <acquire+0x90>
xchg(volatile uint *addr, uint newval)
{
  uint result;
  
  // The + in "+m" denotes a read-modify-write operand.
  asm volatile("lock; xchgl %0, %1" :
  10430b:	b9 01 00 00 00       	mov    $0x1,%ecx
  104310:	eb 09                	jmp    10431b <acquire+0x5b>
  104312:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    panic("acquire");

  // The xchg is atomic.
  // It also serializes, so that reads after acquire are not
  // reordered before it. 
  while(xchg(&lk->locked, 1) != 0)
  104318:	8b 55 08             	mov    0x8(%ebp),%edx
  10431b:	89 c8                	mov    %ecx,%eax
  10431d:	f0 87 02             	lock xchg %eax,(%edx)
  104320:	85 c0                	test   %eax,%eax
  104322:	75 f4                	jne    104318 <acquire+0x58>
    ;

  // Record info about lock acquisition for debugging.
  lk->cpu = cpu;
  104324:	8b 45 08             	mov    0x8(%ebp),%eax
  104327:	65 8b 15 00 00 00 00 	mov    %gs:0x0,%edx
  10432e:	89 50 08             	mov    %edx,0x8(%eax)
  getcallerpcs(&lk, lk->pcs);
  104331:	8b 45 08             	mov    0x8(%ebp),%eax
  104334:	83 c0 0c             	add    $0xc,%eax
  104337:	89 44 24 04          	mov    %eax,0x4(%esp)
  10433b:	8d 45 08             	lea    0x8(%ebp),%eax
  10433e:	89 04 24             	mov    %eax,(%esp)
  104341:	e8 0a fe ff ff       	call   104150 <getcallerpcs>
}
  104346:	83 c4 14             	add    $0x14,%esp
  104349:	5b                   	pop    %ebx
  10434a:	5d                   	pop    %ebp
  10434b:	c3                   	ret    
  10434c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
void
acquire(struct spinlock *lk)
{
  pushcli();
  if(holding(lk))
    panic("acquire");
  104350:	c7 04 24 7a 72 10 00 	movl   $0x10727a,(%esp)
  104357:	e8 04 c7 ff ff       	call   100a60 <panic>
  10435c:	90                   	nop
  10435d:	90                   	nop
  10435e:	90                   	nop
  10435f:	90                   	nop

00104360 <memset>:
#include "types.h"
#include "x86.h"

void*
memset(void *dst, int c, uint n)
{
  104360:	55                   	push   %ebp
  104361:	89 e5                	mov    %esp,%ebp
  104363:	8b 55 08             	mov    0x8(%ebp),%edx
  104366:	57                   	push   %edi
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
  104367:	8b 4d 10             	mov    0x10(%ebp),%ecx
  10436a:	8b 45 0c             	mov    0xc(%ebp),%eax
  10436d:	89 d7                	mov    %edx,%edi
  10436f:	fc                   	cld    
  104370:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
  104372:	89 d0                	mov    %edx,%eax
  104374:	5f                   	pop    %edi
  104375:	5d                   	pop    %ebp
  104376:	c3                   	ret    
  104377:	89 f6                	mov    %esi,%esi
  104379:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104380 <memcmp>:

int
memcmp(const void *v1, const void *v2, uint n)
{
  104380:	55                   	push   %ebp
  104381:	89 e5                	mov    %esp,%ebp
  104383:	57                   	push   %edi
  104384:	56                   	push   %esi
  104385:	53                   	push   %ebx
  104386:	8b 55 10             	mov    0x10(%ebp),%edx
  104389:	8b 75 08             	mov    0x8(%ebp),%esi
  10438c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  const uchar *s1, *s2;
  
  s1 = v1;
  s2 = v2;
  while(n-- > 0){
  10438f:	85 d2                	test   %edx,%edx
  104391:	74 2d                	je     1043c0 <memcmp+0x40>
    if(*s1 != *s2)
  104393:	0f b6 1e             	movzbl (%esi),%ebx
  104396:	0f b6 0f             	movzbl (%edi),%ecx
  104399:	38 cb                	cmp    %cl,%bl
  10439b:	75 2b                	jne    1043c8 <memcmp+0x48>
      return *s1 - *s2;
  10439d:	83 ea 01             	sub    $0x1,%edx
  1043a0:	31 c0                	xor    %eax,%eax
  1043a2:	eb 18                	jmp    1043bc <memcmp+0x3c>
  1043a4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  const uchar *s1, *s2;
  
  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    if(*s1 != *s2)
  1043a8:	0f b6 5c 06 01       	movzbl 0x1(%esi,%eax,1),%ebx
  1043ad:	83 ea 01             	sub    $0x1,%edx
  1043b0:	0f b6 4c 07 01       	movzbl 0x1(%edi,%eax,1),%ecx
  1043b5:	83 c0 01             	add    $0x1,%eax
  1043b8:	38 cb                	cmp    %cl,%bl
  1043ba:	75 0c                	jne    1043c8 <memcmp+0x48>
{
  const uchar *s1, *s2;
  
  s1 = v1;
  s2 = v2;
  while(n-- > 0){
  1043bc:	85 d2                	test   %edx,%edx
  1043be:	75 e8                	jne    1043a8 <memcmp+0x28>
  1043c0:	31 c0                	xor    %eax,%eax
      return *s1 - *s2;
    s1++, s2++;
  }

  return 0;
}
  1043c2:	5b                   	pop    %ebx
  1043c3:	5e                   	pop    %esi
  1043c4:	5f                   	pop    %edi
  1043c5:	5d                   	pop    %ebp
  1043c6:	c3                   	ret    
  1043c7:	90                   	nop
  
  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    if(*s1 != *s2)
      return *s1 - *s2;
  1043c8:	0f b6 c3             	movzbl %bl,%eax
  1043cb:	0f b6 c9             	movzbl %cl,%ecx
  1043ce:	29 c8                	sub    %ecx,%eax
    s1++, s2++;
  }

  return 0;
}
  1043d0:	5b                   	pop    %ebx
  1043d1:	5e                   	pop    %esi
  1043d2:	5f                   	pop    %edi
  1043d3:	5d                   	pop    %ebp
  1043d4:	c3                   	ret    
  1043d5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1043d9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001043e0 <memmove>:

void*
memmove(void *dst, const void *src, uint n)
{
  1043e0:	55                   	push   %ebp
  1043e1:	89 e5                	mov    %esp,%ebp
  1043e3:	57                   	push   %edi
  1043e4:	56                   	push   %esi
  1043e5:	53                   	push   %ebx
  1043e6:	8b 45 08             	mov    0x8(%ebp),%eax
  1043e9:	8b 75 0c             	mov    0xc(%ebp),%esi
  1043ec:	8b 5d 10             	mov    0x10(%ebp),%ebx
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
  1043ef:	39 c6                	cmp    %eax,%esi
  1043f1:	73 2d                	jae    104420 <memmove+0x40>
  1043f3:	8d 3c 1e             	lea    (%esi,%ebx,1),%edi
  1043f6:	39 f8                	cmp    %edi,%eax
  1043f8:	73 26                	jae    104420 <memmove+0x40>
    s += n;
    d += n;
    while(n-- > 0)
  1043fa:	85 db                	test   %ebx,%ebx
  1043fc:	74 1d                	je     10441b <memmove+0x3b>

  s = src;
  d = dst;
  if(s < d && s + n > d){
    s += n;
    d += n;
  1043fe:	8d 34 18             	lea    (%eax,%ebx,1),%esi
  104401:	31 d2                	xor    %edx,%edx
  104403:	90                   	nop
  104404:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    while(n-- > 0)
      *--d = *--s;
  104408:	0f b6 4c 17 ff       	movzbl -0x1(%edi,%edx,1),%ecx
  10440d:	88 4c 16 ff          	mov    %cl,-0x1(%esi,%edx,1)
  104411:	83 ea 01             	sub    $0x1,%edx
  s = src;
  d = dst;
  if(s < d && s + n > d){
    s += n;
    d += n;
    while(n-- > 0)
  104414:	8d 0c 1a             	lea    (%edx,%ebx,1),%ecx
  104417:	85 c9                	test   %ecx,%ecx
  104419:	75 ed                	jne    104408 <memmove+0x28>
  } else
    while(n-- > 0)
      *d++ = *s++;

  return dst;
}
  10441b:	5b                   	pop    %ebx
  10441c:	5e                   	pop    %esi
  10441d:	5f                   	pop    %edi
  10441e:	5d                   	pop    %ebp
  10441f:	c3                   	ret    
  s = src;
  d = dst;
  if(s < d && s + n > d){
    s += n;
    d += n;
    while(n-- > 0)
  104420:	31 d2                	xor    %edx,%edx
      *--d = *--s;
  } else
    while(n-- > 0)
  104422:	85 db                	test   %ebx,%ebx
  104424:	74 f5                	je     10441b <memmove+0x3b>
  104426:	66 90                	xchg   %ax,%ax
      *d++ = *s++;
  104428:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
  10442c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  10442f:	83 c2 01             	add    $0x1,%edx
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
  104432:	39 d3                	cmp    %edx,%ebx
  104434:	75 f2                	jne    104428 <memmove+0x48>
      *d++ = *s++;

  return dst;
}
  104436:	5b                   	pop    %ebx
  104437:	5e                   	pop    %esi
  104438:	5f                   	pop    %edi
  104439:	5d                   	pop    %ebp
  10443a:	c3                   	ret    
  10443b:	90                   	nop
  10443c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00104440 <memcpy>:

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
  104440:	55                   	push   %ebp
  104441:	89 e5                	mov    %esp,%ebp
  return memmove(dst, src, n);
}
  104443:	5d                   	pop    %ebp

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
  return memmove(dst, src, n);
  104444:	e9 97 ff ff ff       	jmp    1043e0 <memmove>
  104449:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00104450 <strncmp>:
}

int
strncmp(const char *p, const char *q, uint n)
{
  104450:	55                   	push   %ebp
  104451:	89 e5                	mov    %esp,%ebp
  104453:	57                   	push   %edi
  104454:	56                   	push   %esi
  104455:	53                   	push   %ebx
  104456:	8b 7d 10             	mov    0x10(%ebp),%edi
  104459:	8b 4d 08             	mov    0x8(%ebp),%ecx
  10445c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  while(n > 0 && *p && *p == *q)
  10445f:	85 ff                	test   %edi,%edi
  104461:	74 3d                	je     1044a0 <strncmp+0x50>
  104463:	0f b6 01             	movzbl (%ecx),%eax
  104466:	84 c0                	test   %al,%al
  104468:	75 18                	jne    104482 <strncmp+0x32>
  10446a:	eb 3c                	jmp    1044a8 <strncmp+0x58>
  10446c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  104470:	83 ef 01             	sub    $0x1,%edi
  104473:	74 2b                	je     1044a0 <strncmp+0x50>
    n--, p++, q++;
  104475:	83 c1 01             	add    $0x1,%ecx
  104478:	83 c3 01             	add    $0x1,%ebx
}

int
strncmp(const char *p, const char *q, uint n)
{
  while(n > 0 && *p && *p == *q)
  10447b:	0f b6 01             	movzbl (%ecx),%eax
  10447e:	84 c0                	test   %al,%al
  104480:	74 26                	je     1044a8 <strncmp+0x58>
  104482:	0f b6 33             	movzbl (%ebx),%esi
  104485:	89 f2                	mov    %esi,%edx
  104487:	38 d0                	cmp    %dl,%al
  104489:	74 e5                	je     104470 <strncmp+0x20>
    n--, p++, q++;
  if(n == 0)
    return 0;
  return (uchar)*p - (uchar)*q;
  10448b:	81 e6 ff 00 00 00    	and    $0xff,%esi
  104491:	0f b6 c0             	movzbl %al,%eax
  104494:	29 f0                	sub    %esi,%eax
}
  104496:	5b                   	pop    %ebx
  104497:	5e                   	pop    %esi
  104498:	5f                   	pop    %edi
  104499:	5d                   	pop    %ebp
  10449a:	c3                   	ret    
  10449b:	90                   	nop
  10449c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
}

int
strncmp(const char *p, const char *q, uint n)
{
  while(n > 0 && *p && *p == *q)
  1044a0:	31 c0                	xor    %eax,%eax
    n--, p++, q++;
  if(n == 0)
    return 0;
  return (uchar)*p - (uchar)*q;
}
  1044a2:	5b                   	pop    %ebx
  1044a3:	5e                   	pop    %esi
  1044a4:	5f                   	pop    %edi
  1044a5:	5d                   	pop    %ebp
  1044a6:	c3                   	ret    
  1044a7:	90                   	nop
}

int
strncmp(const char *p, const char *q, uint n)
{
  while(n > 0 && *p && *p == *q)
  1044a8:	0f b6 33             	movzbl (%ebx),%esi
  1044ab:	eb de                	jmp    10448b <strncmp+0x3b>
  1044ad:	8d 76 00             	lea    0x0(%esi),%esi

001044b0 <strncpy>:
  return (uchar)*p - (uchar)*q;
}

char*
strncpy(char *s, const char *t, int n)
{
  1044b0:	55                   	push   %ebp
  1044b1:	89 e5                	mov    %esp,%ebp
  1044b3:	8b 45 08             	mov    0x8(%ebp),%eax
  1044b6:	56                   	push   %esi
  1044b7:	8b 4d 10             	mov    0x10(%ebp),%ecx
  1044ba:	53                   	push   %ebx
  1044bb:	8b 75 0c             	mov    0xc(%ebp),%esi
  1044be:	89 c3                	mov    %eax,%ebx
  1044c0:	eb 09                	jmp    1044cb <strncpy+0x1b>
  1044c2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  char *os;
  
  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
  1044c8:	83 c6 01             	add    $0x1,%esi
  1044cb:	83 e9 01             	sub    $0x1,%ecx
    return 0;
  return (uchar)*p - (uchar)*q;
}

char*
strncpy(char *s, const char *t, int n)
  1044ce:	8d 51 01             	lea    0x1(%ecx),%edx
{
  char *os;
  
  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
  1044d1:	85 d2                	test   %edx,%edx
  1044d3:	7e 0c                	jle    1044e1 <strncpy+0x31>
  1044d5:	0f b6 16             	movzbl (%esi),%edx
  1044d8:	88 13                	mov    %dl,(%ebx)
  1044da:	83 c3 01             	add    $0x1,%ebx
  1044dd:	84 d2                	test   %dl,%dl
  1044df:	75 e7                	jne    1044c8 <strncpy+0x18>
    return 0;
  return (uchar)*p - (uchar)*q;
}

char*
strncpy(char *s, const char *t, int n)
  1044e1:	31 d2                	xor    %edx,%edx
  char *os;
  
  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    ;
  while(n-- > 0)
  1044e3:	85 c9                	test   %ecx,%ecx
  1044e5:	7e 0c                	jle    1044f3 <strncpy+0x43>
  1044e7:	90                   	nop
    *s++ = 0;
  1044e8:	c6 04 13 00          	movb   $0x0,(%ebx,%edx,1)
  1044ec:	83 c2 01             	add    $0x1,%edx
  char *os;
  
  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    ;
  while(n-- > 0)
  1044ef:	39 ca                	cmp    %ecx,%edx
  1044f1:	75 f5                	jne    1044e8 <strncpy+0x38>
    *s++ = 0;
  return os;
}
  1044f3:	5b                   	pop    %ebx
  1044f4:	5e                   	pop    %esi
  1044f5:	5d                   	pop    %ebp
  1044f6:	c3                   	ret    
  1044f7:	89 f6                	mov    %esi,%esi
  1044f9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104500 <safestrcpy>:

// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
  104500:	55                   	push   %ebp
  104501:	89 e5                	mov    %esp,%ebp
  104503:	8b 55 10             	mov    0x10(%ebp),%edx
  104506:	56                   	push   %esi
  104507:	8b 45 08             	mov    0x8(%ebp),%eax
  10450a:	53                   	push   %ebx
  10450b:	8b 75 0c             	mov    0xc(%ebp),%esi
  char *os;
  
  os = s;
  if(n <= 0)
  10450e:	85 d2                	test   %edx,%edx
  104510:	7e 1f                	jle    104531 <safestrcpy+0x31>
  104512:	89 c1                	mov    %eax,%ecx
  104514:	eb 05                	jmp    10451b <safestrcpy+0x1b>
  104516:	66 90                	xchg   %ax,%ax
    return os;
  while(--n > 0 && (*s++ = *t++) != 0)
  104518:	83 c6 01             	add    $0x1,%esi
  10451b:	83 ea 01             	sub    $0x1,%edx
  10451e:	85 d2                	test   %edx,%edx
  104520:	7e 0c                	jle    10452e <safestrcpy+0x2e>
  104522:	0f b6 1e             	movzbl (%esi),%ebx
  104525:	88 19                	mov    %bl,(%ecx)
  104527:	83 c1 01             	add    $0x1,%ecx
  10452a:	84 db                	test   %bl,%bl
  10452c:	75 ea                	jne    104518 <safestrcpy+0x18>
    ;
  *s = 0;
  10452e:	c6 01 00             	movb   $0x0,(%ecx)
  return os;
}
  104531:	5b                   	pop    %ebx
  104532:	5e                   	pop    %esi
  104533:	5d                   	pop    %ebp
  104534:	c3                   	ret    
  104535:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  104539:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104540 <strlen>:

int
strlen(const char *s)
{
  104540:	55                   	push   %ebp
  int n;

  for(n = 0; s[n]; n++)
  104541:	31 c0                	xor    %eax,%eax
  return os;
}

int
strlen(const char *s)
{
  104543:	89 e5                	mov    %esp,%ebp
  104545:	8b 55 08             	mov    0x8(%ebp),%edx
  int n;

  for(n = 0; s[n]; n++)
  104548:	80 3a 00             	cmpb   $0x0,(%edx)
  10454b:	74 0c                	je     104559 <strlen+0x19>
  10454d:	8d 76 00             	lea    0x0(%esi),%esi
  104550:	83 c0 01             	add    $0x1,%eax
  104553:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  104557:	75 f7                	jne    104550 <strlen+0x10>
    ;
  return n;
}
  104559:	5d                   	pop    %ebp
  10455a:	c3                   	ret    
  10455b:	90                   	nop

0010455c <swtch>:
# Save current register context in old
# and then load register context from new.

.globl swtch
swtch:
  movl 4(%esp), %eax
  10455c:	8b 44 24 04          	mov    0x4(%esp),%eax
  movl 8(%esp), %edx
  104560:	8b 54 24 08          	mov    0x8(%esp),%edx

  # Save old callee-save registers
  pushl %ebp
  104564:	55                   	push   %ebp
  pushl %ebx
  104565:	53                   	push   %ebx
  pushl %esi
  104566:	56                   	push   %esi
  pushl %edi
  104567:	57                   	push   %edi

  # Switch stacks
  movl %esp, (%eax)
  104568:	89 20                	mov    %esp,(%eax)
  movl %edx, %esp
  10456a:	89 d4                	mov    %edx,%esp

  # Load new callee-save registers
  popl %edi
  10456c:	5f                   	pop    %edi
  popl %esi
  10456d:	5e                   	pop    %esi
  popl %ebx
  10456e:	5b                   	pop    %ebx
  popl %ebp
  10456f:	5d                   	pop    %ebp
  ret
  104570:	c3                   	ret    
  104571:	90                   	nop
  104572:	90                   	nop
  104573:	90                   	nop
  104574:	90                   	nop
  104575:	90                   	nop
  104576:	90                   	nop
  104577:	90                   	nop
  104578:	90                   	nop
  104579:	90                   	nop
  10457a:	90                   	nop
  10457b:	90                   	nop
  10457c:	90                   	nop
  10457d:	90                   	nop
  10457e:	90                   	nop
  10457f:	90                   	nop

00104580 <fetchint>:
// to a saved program counter, and then the first argument.

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  104580:	55                   	push   %ebp
  104581:	89 e5                	mov    %esp,%ebp
  if(addr >= p->sz || addr+4 > p->sz)
  104583:	8b 55 08             	mov    0x8(%ebp),%edx
// to a saved program counter, and then the first argument.

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  104586:	8b 45 0c             	mov    0xc(%ebp),%eax
  if(addr >= p->sz || addr+4 > p->sz)
  104589:	8b 12                	mov    (%edx),%edx
  10458b:	39 c2                	cmp    %eax,%edx
  10458d:	77 09                	ja     104598 <fetchint+0x18>
    return -1;
  *ip = *(int*)(addr);
  return 0;
  10458f:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104594:	5d                   	pop    %ebp
  104595:	c3                   	ret    
  104596:	66 90                	xchg   %ax,%ax

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  104598:	8d 48 04             	lea    0x4(%eax),%ecx
  10459b:	39 ca                	cmp    %ecx,%edx
  10459d:	72 f0                	jb     10458f <fetchint+0xf>
    return -1;
  *ip = *(int*)(addr);
  10459f:	8b 10                	mov    (%eax),%edx
  1045a1:	8b 45 10             	mov    0x10(%ebp),%eax
  1045a4:	89 10                	mov    %edx,(%eax)
  1045a6:	31 c0                	xor    %eax,%eax
  return 0;
}
  1045a8:	5d                   	pop    %ebp
  1045a9:	c3                   	ret    
  1045aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

001045b0 <fetchstr>:
// Fetch the nul-terminated string at addr from process p.
// Doesn't actually copy the string - just sets *pp to point at it.
// Returns length of string, not including nul.
int
fetchstr(struct proc *p, uint addr, char **pp)
{
  1045b0:	55                   	push   %ebp
  1045b1:	89 e5                	mov    %esp,%ebp
  1045b3:	8b 45 08             	mov    0x8(%ebp),%eax
  1045b6:	8b 55 0c             	mov    0xc(%ebp),%edx
  1045b9:	53                   	push   %ebx
  char *s, *ep;

  if(addr >= p->sz)
  1045ba:	39 10                	cmp    %edx,(%eax)
  1045bc:	77 0a                	ja     1045c8 <fetchstr+0x18>
    return -1;
  *pp = (char *) addr;
  ep = (char *) p->sz;
  for(s = *pp; s < ep; s++)
  1045be:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    if(*s == 0)
      return s - *pp;
  return -1;
}
  1045c3:	5b                   	pop    %ebx
  1045c4:	5d                   	pop    %ebp
  1045c5:	c3                   	ret    
  1045c6:	66 90                	xchg   %ax,%ax
{
  char *s, *ep;

  if(addr >= p->sz)
    return -1;
  *pp = (char *) addr;
  1045c8:	8b 4d 10             	mov    0x10(%ebp),%ecx
  1045cb:	89 11                	mov    %edx,(%ecx)
  ep = (char *) p->sz;
  1045cd:	8b 18                	mov    (%eax),%ebx
  for(s = *pp; s < ep; s++)
  1045cf:	39 da                	cmp    %ebx,%edx
  1045d1:	73 eb                	jae    1045be <fetchstr+0xe>
    if(*s == 0)
  1045d3:	31 c0                	xor    %eax,%eax
  1045d5:	89 d1                	mov    %edx,%ecx
  1045d7:	80 3a 00             	cmpb   $0x0,(%edx)
  1045da:	74 e7                	je     1045c3 <fetchstr+0x13>
  1045dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

  if(addr >= p->sz)
    return -1;
  *pp = (char *) addr;
  ep = (char *) p->sz;
  for(s = *pp; s < ep; s++)
  1045e0:	83 c1 01             	add    $0x1,%ecx
  1045e3:	39 cb                	cmp    %ecx,%ebx
  1045e5:	76 d7                	jbe    1045be <fetchstr+0xe>
    if(*s == 0)
  1045e7:	80 39 00             	cmpb   $0x0,(%ecx)
  1045ea:	75 f4                	jne    1045e0 <fetchstr+0x30>
  1045ec:	89 c8                	mov    %ecx,%eax
  1045ee:	29 d0                	sub    %edx,%eax
  1045f0:	eb d1                	jmp    1045c3 <fetchstr+0x13>
  1045f2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  1045f9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104600 <argint>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104600:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
}

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  104606:	55                   	push   %ebp
  104607:	89 e5                	mov    %esp,%ebp
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104609:	8b 4d 08             	mov    0x8(%ebp),%ecx
  10460c:	8b 50 18             	mov    0x18(%eax),%edx

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  10460f:	8b 00                	mov    (%eax),%eax

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104611:	8b 52 44             	mov    0x44(%edx),%edx
  104614:	8d 54 8a 04          	lea    0x4(%edx,%ecx,4),%edx

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  104618:	39 c2                	cmp    %eax,%edx
  10461a:	72 0c                	jb     104628 <argint+0x28>
    return -1;
  *ip = *(int*)(addr);
  10461c:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  return x;
}
  104621:	5d                   	pop    %ebp
  104622:	c3                   	ret    
  104623:	90                   	nop
  104624:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  104628:	8d 4a 04             	lea    0x4(%edx),%ecx
  10462b:	39 c8                	cmp    %ecx,%eax
  10462d:	72 ed                	jb     10461c <argint+0x1c>
    return -1;
  *ip = *(int*)(addr);
  10462f:	8b 45 0c             	mov    0xc(%ebp),%eax
  104632:	8b 12                	mov    (%edx),%edx
  104634:	89 10                	mov    %edx,(%eax)
  104636:	31 c0                	xor    %eax,%eax
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  return x;
}
  104638:	5d                   	pop    %ebp
  104639:	c3                   	ret    
  10463a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00104640 <argptr>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104640:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
// Fetch the nth word-sized system call argument as a pointer
// to a block of memory of size n bytes.  Check that the pointer
// lies within the process address space.
int
argptr(int n, char **pp, int size)
{
  104646:	55                   	push   %ebp
  104647:	89 e5                	mov    %esp,%ebp

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104649:	8b 4d 08             	mov    0x8(%ebp),%ecx
  10464c:	8b 50 18             	mov    0x18(%eax),%edx

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  10464f:	8b 00                	mov    (%eax),%eax

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104651:	8b 52 44             	mov    0x44(%edx),%edx
  104654:	8d 54 8a 04          	lea    0x4(%edx,%ecx,4),%edx

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  104658:	39 c2                	cmp    %eax,%edx
  10465a:	73 07                	jae    104663 <argptr+0x23>
  10465c:	8d 4a 04             	lea    0x4(%edx),%ecx
  10465f:	39 c8                	cmp    %ecx,%eax
  104661:	73 0d                	jae    104670 <argptr+0x30>
  if(argint(n, &i) < 0)
    return -1;
  if((uint)i >= proc->sz || (uint)i+size >= proc->sz)
    return -1;
  *pp = (char *) i;
  return 0;
  104663:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104668:	5d                   	pop    %ebp
  104669:	c3                   	ret    
  10466a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
    return -1;
  *ip = *(int*)(addr);
  104670:	8b 12                	mov    (%edx),%edx
{
  int i;
  
  if(argint(n, &i) < 0)
    return -1;
  if((uint)i >= proc->sz || (uint)i+size >= proc->sz)
  104672:	39 c2                	cmp    %eax,%edx
  104674:	73 ed                	jae    104663 <argptr+0x23>
  104676:	8b 4d 10             	mov    0x10(%ebp),%ecx
  104679:	01 d1                	add    %edx,%ecx
  10467b:	39 c1                	cmp    %eax,%ecx
  10467d:	73 e4                	jae    104663 <argptr+0x23>
    return -1;
  *pp = (char *) i;
  10467f:	8b 45 0c             	mov    0xc(%ebp),%eax
  104682:	89 10                	mov    %edx,(%eax)
  104684:	31 c0                	xor    %eax,%eax
  return 0;
}
  104686:	5d                   	pop    %ebp
  104687:	c3                   	ret    
  104688:	90                   	nop
  104689:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00104690 <argstr>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  104690:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
// Check that the pointer is valid and the string is nul-terminated.
// (There is no shared writable memory, so the string can't change
// between this check and being used by the kernel.)
int
argstr(int n, char **pp)
{
  104697:	55                   	push   %ebp
  104698:	89 e5                	mov    %esp,%ebp
  10469a:	53                   	push   %ebx

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
  int x = fetchint(proc, proc->tf->esp + 4 + 4*n, ip);
  10469b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  10469e:	8b 42 18             	mov    0x18(%edx),%eax
  1046a1:	8b 40 44             	mov    0x44(%eax),%eax
  1046a4:	8d 44 88 04          	lea    0x4(%eax,%ecx,4),%eax

// Fetch the int at addr from process p.
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
  1046a8:	8b 0a                	mov    (%edx),%ecx
  1046aa:	39 c8                	cmp    %ecx,%eax
  1046ac:	73 07                	jae    1046b5 <argstr+0x25>
  1046ae:	8d 58 04             	lea    0x4(%eax),%ebx
  1046b1:	39 d9                	cmp    %ebx,%ecx
  1046b3:	73 0b                	jae    1046c0 <argstr+0x30>

  if(addr >= p->sz)
    return -1;
  *pp = (char *) addr;
  ep = (char *) p->sz;
  for(s = *pp; s < ep; s++)
  1046b5:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
{
  int addr;
  if(argint(n, &addr) < 0)
    return -1;
  return fetchstr(proc, addr, pp);
}
  1046ba:	5b                   	pop    %ebx
  1046bb:	5d                   	pop    %ebp
  1046bc:	c3                   	ret    
  1046bd:	8d 76 00             	lea    0x0(%esi),%esi
int
fetchint(struct proc *p, uint addr, int *ip)
{
  if(addr >= p->sz || addr+4 > p->sz)
    return -1;
  *ip = *(int*)(addr);
  1046c0:	8b 18                	mov    (%eax),%ebx
int
fetchstr(struct proc *p, uint addr, char **pp)
{
  char *s, *ep;

  if(addr >= p->sz)
  1046c2:	39 cb                	cmp    %ecx,%ebx
  1046c4:	73 ef                	jae    1046b5 <argstr+0x25>
    return -1;
  *pp = (char *) addr;
  1046c6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  1046c9:	89 d8                	mov    %ebx,%eax
  1046cb:	89 19                	mov    %ebx,(%ecx)
  ep = (char *) p->sz;
  1046cd:	8b 12                	mov    (%edx),%edx
  for(s = *pp; s < ep; s++)
  1046cf:	39 d3                	cmp    %edx,%ebx
  1046d1:	73 e2                	jae    1046b5 <argstr+0x25>
    if(*s == 0)
  1046d3:	80 3b 00             	cmpb   $0x0,(%ebx)
  1046d6:	75 12                	jne    1046ea <argstr+0x5a>
  1046d8:	eb 1e                	jmp    1046f8 <argstr+0x68>
  1046da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  1046e0:	80 38 00             	cmpb   $0x0,(%eax)
  1046e3:	90                   	nop
  1046e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1046e8:	74 0e                	je     1046f8 <argstr+0x68>

  if(addr >= p->sz)
    return -1;
  *pp = (char *) addr;
  ep = (char *) p->sz;
  for(s = *pp; s < ep; s++)
  1046ea:	83 c0 01             	add    $0x1,%eax
  1046ed:	39 c2                	cmp    %eax,%edx
  1046ef:	90                   	nop
  1046f0:	77 ee                	ja     1046e0 <argstr+0x50>
  1046f2:	eb c1                	jmp    1046b5 <argstr+0x25>
  1046f4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    if(*s == 0)
      return s - *pp;
  1046f8:	29 d8                	sub    %ebx,%eax
{
  int addr;
  if(argint(n, &addr) < 0)
    return -1;
  return fetchstr(proc, addr, pp);
}
  1046fa:	5b                   	pop    %ebx
  1046fb:	5d                   	pop    %ebp
  1046fc:	c3                   	ret    
  1046fd:	8d 76 00             	lea    0x0(%esi),%esi

00104700 <syscall>:
[SYS_nice]    sys_nice,
};

void
syscall(void)
{
  104700:	55                   	push   %ebp
  104701:	89 e5                	mov    %esp,%ebp
  104703:	53                   	push   %ebx
  104704:	83 ec 14             	sub    $0x14,%esp
  int num;
  
  num = proc->tf->eax;
  104707:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  10470e:	8b 5a 18             	mov    0x18(%edx),%ebx
  104711:	8b 43 1c             	mov    0x1c(%ebx),%eax
  if(num >= 0 && num < NELEM(syscalls) && syscalls[num])
  104714:	83 f8 17             	cmp    $0x17,%eax
  104717:	77 17                	ja     104730 <syscall+0x30>
  104719:	8b 0c 85 a0 72 10 00 	mov    0x1072a0(,%eax,4),%ecx
  104720:	85 c9                	test   %ecx,%ecx
  104722:	74 0c                	je     104730 <syscall+0x30>
    proc->tf->eax = syscalls[num]();
  104724:	ff d1                	call   *%ecx
  104726:	89 43 1c             	mov    %eax,0x1c(%ebx)
  else {
    cprintf("%d %s: unknown sys call %d\n",
            proc->pid, proc->name, num);
    proc->tf->eax = -1;
  }
}
  104729:	83 c4 14             	add    $0x14,%esp
  10472c:	5b                   	pop    %ebx
  10472d:	5d                   	pop    %ebp
  10472e:	c3                   	ret    
  10472f:	90                   	nop
  
  num = proc->tf->eax;
  if(num >= 0 && num < NELEM(syscalls) && syscalls[num])
    proc->tf->eax = syscalls[num]();
  else {
    cprintf("%d %s: unknown sys call %d\n",
  104730:	8b 4a 10             	mov    0x10(%edx),%ecx
  104733:	83 c2 6c             	add    $0x6c,%edx
  104736:	89 44 24 0c          	mov    %eax,0xc(%esp)
  10473a:	89 54 24 08          	mov    %edx,0x8(%esp)
  10473e:	c7 04 24 82 72 10 00 	movl   $0x107282,(%esp)
  104745:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  104749:	e8 72 bd ff ff       	call   1004c0 <cprintf>
            proc->pid, proc->name, num);
    proc->tf->eax = -1;
  10474e:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  104754:	8b 40 18             	mov    0x18(%eax),%eax
  104757:	c7 40 1c ff ff ff ff 	movl   $0xffffffff,0x1c(%eax)
  }
}
  10475e:	83 c4 14             	add    $0x14,%esp
  104761:	5b                   	pop    %ebx
  104762:	5d                   	pop    %ebp
  104763:	c3                   	ret    
  104764:	90                   	nop
  104765:	90                   	nop
  104766:	90                   	nop
  104767:	90                   	nop
  104768:	90                   	nop
  104769:	90                   	nop
  10476a:	90                   	nop
  10476b:	90                   	nop
  10476c:	90                   	nop
  10476d:	90                   	nop
  10476e:	90                   	nop
  10476f:	90                   	nop

00104770 <sys_pipe>:
  return exec(path, argv);
}

int
sys_pipe(void)
{
  104770:	55                   	push   %ebp
  104771:	89 e5                	mov    %esp,%ebp
  104773:	83 ec 28             	sub    $0x28,%esp
  int *fd;
  struct file *rf, *wf;
  int fd0, fd1;

  if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0)
  104776:	8d 45 f4             	lea    -0xc(%ebp),%eax
  return exec(path, argv);
}

int
sys_pipe(void)
{
  104779:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  10477c:	89 75 fc             	mov    %esi,-0x4(%ebp)
  int *fd;
  struct file *rf, *wf;
  int fd0, fd1;

  if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0)
  10477f:	c7 44 24 08 08 00 00 	movl   $0x8,0x8(%esp)
  104786:	00 
  104787:	89 44 24 04          	mov    %eax,0x4(%esp)
  10478b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104792:	e8 a9 fe ff ff       	call   104640 <argptr>
  104797:	85 c0                	test   %eax,%eax
  104799:	79 15                	jns    1047b0 <sys_pipe+0x40>
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    if(fd0 >= 0)
      proc->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  10479b:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  }
  fd[0] = fd0;
  fd[1] = fd1;
  return 0;
}
  1047a0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  1047a3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  1047a6:	89 ec                	mov    %ebp,%esp
  1047a8:	5d                   	pop    %ebp
  1047a9:	c3                   	ret    
  1047aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  struct file *rf, *wf;
  int fd0, fd1;

  if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0)
    return -1;
  if(pipealloc(&rf, &wf) < 0)
  1047b0:	8d 45 ec             	lea    -0x14(%ebp),%eax
  1047b3:	89 44 24 04          	mov    %eax,0x4(%esp)
  1047b7:	8d 45 f0             	lea    -0x10(%ebp),%eax
  1047ba:	89 04 24             	mov    %eax,(%esp)
  1047bd:	e8 ce e8 ff ff       	call   103090 <pipealloc>
  1047c2:	85 c0                	test   %eax,%eax
  1047c4:	78 d5                	js     10479b <sys_pipe+0x2b>
    return -1;
  fd0 = -1;
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
  1047c6:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  1047c9:	31 c0                	xor    %eax,%eax
  1047cb:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  1047d2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd] == 0){
  1047d8:	8b 5c 82 28          	mov    0x28(%edx,%eax,4),%ebx
  1047dc:	85 db                	test   %ebx,%ebx
  1047de:	74 28                	je     104808 <sys_pipe+0x98>
static int
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
  1047e0:	83 c0 01             	add    $0x1,%eax
  1047e3:	83 f8 10             	cmp    $0x10,%eax
  1047e6:	75 f0                	jne    1047d8 <sys_pipe+0x68>
    return -1;
  fd0 = -1;
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    if(fd0 >= 0)
      proc->ofile[fd0] = 0;
    fileclose(rf);
  1047e8:	89 0c 24             	mov    %ecx,(%esp)
  1047eb:	e8 20 c9 ff ff       	call   101110 <fileclose>
    fileclose(wf);
  1047f0:	8b 45 ec             	mov    -0x14(%ebp),%eax
  1047f3:	89 04 24             	mov    %eax,(%esp)
  1047f6:	e8 15 c9 ff ff       	call   101110 <fileclose>
  1047fb:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    return -1;
  104800:	eb 9e                	jmp    1047a0 <sys_pipe+0x30>
  104802:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd] == 0){
      proc->ofile[fd] = f;
  104808:	8d 58 08             	lea    0x8(%eax),%ebx
  10480b:	89 4c 9a 08          	mov    %ecx,0x8(%edx,%ebx,4)
  if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0)
    return -1;
  if(pipealloc(&rf, &wf) < 0)
    return -1;
  fd0 = -1;
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
  10480f:	8b 75 ec             	mov    -0x14(%ebp),%esi
  104812:	31 d2                	xor    %edx,%edx
  104814:	65 8b 0d 04 00 00 00 	mov    %gs:0x4,%ecx
  10481b:	90                   	nop
  10481c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd] == 0){
  104820:	83 7c 91 28 00       	cmpl   $0x0,0x28(%ecx,%edx,4)
  104825:	74 19                	je     104840 <sys_pipe+0xd0>
static int
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
  104827:	83 c2 01             	add    $0x1,%edx
  10482a:	83 fa 10             	cmp    $0x10,%edx
  10482d:	75 f1                	jne    104820 <sys_pipe+0xb0>
  if(pipealloc(&rf, &wf) < 0)
    return -1;
  fd0 = -1;
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    if(fd0 >= 0)
      proc->ofile[fd0] = 0;
  10482f:	c7 44 99 08 00 00 00 	movl   $0x0,0x8(%ecx,%ebx,4)
  104836:	00 
  104837:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  10483a:	eb ac                	jmp    1047e8 <sys_pipe+0x78>
  10483c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd] == 0){
      proc->ofile[fd] = f;
  104840:	89 74 91 28          	mov    %esi,0x28(%ecx,%edx,4)
      proc->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  fd[0] = fd0;
  104844:	8b 4d f4             	mov    -0xc(%ebp),%ecx
  104847:	89 01                	mov    %eax,(%ecx)
  fd[1] = fd1;
  104849:	8b 45 f4             	mov    -0xc(%ebp),%eax
  10484c:	89 50 04             	mov    %edx,0x4(%eax)
  10484f:	31 c0                	xor    %eax,%eax
  return 0;
  104851:	e9 4a ff ff ff       	jmp    1047a0 <sys_pipe+0x30>
  104856:	8d 76 00             	lea    0x0(%esi),%esi
  104859:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104860 <sys_exec>:
  return 0;
}

int
sys_exec(void)
{
  104860:	55                   	push   %ebp
  104861:	89 e5                	mov    %esp,%ebp
  104863:	81 ec 88 00 00 00    	sub    $0x88,%esp
  char *path, *argv[20];
  int i;
  uint uargv, uarg;

  if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) {
  104869:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  return 0;
}

int
sys_exec(void)
{
  10486c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  10486f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  104872:	89 7d fc             	mov    %edi,-0x4(%ebp)
  char *path, *argv[20];
  int i;
  uint uargv, uarg;

  if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) {
  104875:	89 44 24 04          	mov    %eax,0x4(%esp)
  104879:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104880:	e8 0b fe ff ff       	call   104690 <argstr>
  104885:	85 c0                	test   %eax,%eax
  104887:	79 17                	jns    1048a0 <sys_exec+0x40>
    return -1;
  }
  memset(argv, 0, sizeof(argv));
  for(i=0;; i++){
    if(i >= NELEM(argv))
  104889:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    }
    if(fetchstr(proc, uarg, &argv[i]) < 0)
      return -1;
  }
  return exec(path, argv);
}
  10488e:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  104891:	8b 75 f8             	mov    -0x8(%ebp),%esi
  104894:	8b 7d fc             	mov    -0x4(%ebp),%edi
  104897:	89 ec                	mov    %ebp,%esp
  104899:	5d                   	pop    %ebp
  10489a:	c3                   	ret    
  10489b:	90                   	nop
  10489c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
  char *path, *argv[20];
  int i;
  uint uargv, uarg;

  if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) {
  1048a0:	8d 45 e0             	lea    -0x20(%ebp),%eax
  1048a3:	89 44 24 04          	mov    %eax,0x4(%esp)
  1048a7:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  1048ae:	e8 4d fd ff ff       	call   104600 <argint>
  1048b3:	85 c0                	test   %eax,%eax
  1048b5:	78 d2                	js     104889 <sys_exec+0x29>
    return -1;
  }
  memset(argv, 0, sizeof(argv));
  1048b7:	8d 7d 8c             	lea    -0x74(%ebp),%edi
  1048ba:	31 f6                	xor    %esi,%esi
  1048bc:	c7 44 24 08 50 00 00 	movl   $0x50,0x8(%esp)
  1048c3:	00 
  1048c4:	31 db                	xor    %ebx,%ebx
  1048c6:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  1048cd:	00 
  1048ce:	89 3c 24             	mov    %edi,(%esp)
  1048d1:	e8 8a fa ff ff       	call   104360 <memset>
  1048d6:	eb 27                	jmp    1048ff <sys_exec+0x9f>
      return -1;
    if(uarg == 0){
      argv[i] = 0;
      break;
    }
    if(fetchstr(proc, uarg, &argv[i]) < 0)
  1048d8:	89 44 24 04          	mov    %eax,0x4(%esp)
  1048dc:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1048e2:	8d 14 b7             	lea    (%edi,%esi,4),%edx
  1048e5:	89 54 24 08          	mov    %edx,0x8(%esp)
  1048e9:	89 04 24             	mov    %eax,(%esp)
  1048ec:	e8 bf fc ff ff       	call   1045b0 <fetchstr>
  1048f1:	85 c0                	test   %eax,%eax
  1048f3:	78 94                	js     104889 <sys_exec+0x29>

  if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) {
    return -1;
  }
  memset(argv, 0, sizeof(argv));
  for(i=0;; i++){
  1048f5:	83 c3 01             	add    $0x1,%ebx
    if(i >= NELEM(argv))
  1048f8:	83 fb 14             	cmp    $0x14,%ebx

  if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0) {
    return -1;
  }
  memset(argv, 0, sizeof(argv));
  for(i=0;; i++){
  1048fb:	89 de                	mov    %ebx,%esi
    if(i >= NELEM(argv))
  1048fd:	74 8a                	je     104889 <sys_exec+0x29>
      return -1;
    if(fetchint(proc, uargv+4*i, (int*)&uarg) < 0)
  1048ff:	8d 45 dc             	lea    -0x24(%ebp),%eax
  104902:	89 44 24 08          	mov    %eax,0x8(%esp)
  104906:	8d 04 9d 00 00 00 00 	lea    0x0(,%ebx,4),%eax
  10490d:	03 45 e0             	add    -0x20(%ebp),%eax
  104910:	89 44 24 04          	mov    %eax,0x4(%esp)
  104914:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  10491a:	89 04 24             	mov    %eax,(%esp)
  10491d:	e8 5e fc ff ff       	call   104580 <fetchint>
  104922:	85 c0                	test   %eax,%eax
  104924:	0f 88 5f ff ff ff    	js     104889 <sys_exec+0x29>
      return -1;
    if(uarg == 0){
  10492a:	8b 45 dc             	mov    -0x24(%ebp),%eax
  10492d:	85 c0                	test   %eax,%eax
  10492f:	75 a7                	jne    1048d8 <sys_exec+0x78>
      break;
    }
    if(fetchstr(proc, uarg, &argv[i]) < 0)
      return -1;
  }
  return exec(path, argv);
  104931:	8b 45 e4             	mov    -0x1c(%ebp),%eax
    if(i >= NELEM(argv))
      return -1;
    if(fetchint(proc, uargv+4*i, (int*)&uarg) < 0)
      return -1;
    if(uarg == 0){
      argv[i] = 0;
  104934:	c7 44 9d 8c 00 00 00 	movl   $0x0,-0x74(%ebp,%ebx,4)
  10493b:	00 
      break;
    }
    if(fetchstr(proc, uarg, &argv[i]) < 0)
      return -1;
  }
  return exec(path, argv);
  10493c:	89 7c 24 04          	mov    %edi,0x4(%esp)
  104940:	89 04 24             	mov    %eax,(%esp)
  104943:	e8 98 c1 ff ff       	call   100ae0 <exec>
  104948:	e9 41 ff ff ff       	jmp    10488e <sys_exec+0x2e>
  10494d:	8d 76 00             	lea    0x0(%esi),%esi

00104950 <sys_chdir>:
  return 0;
}

int
sys_chdir(void)
{
  104950:	55                   	push   %ebp
  104951:	89 e5                	mov    %esp,%ebp
  104953:	53                   	push   %ebx
  104954:	83 ec 24             	sub    $0x24,%esp
  char *path;
  struct inode *ip;

  if(argstr(0, &path) < 0 || (ip = namei(path)) == 0)
  104957:	8d 45 f4             	lea    -0xc(%ebp),%eax
  10495a:	89 44 24 04          	mov    %eax,0x4(%esp)
  10495e:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104965:	e8 26 fd ff ff       	call   104690 <argstr>
  10496a:	85 c0                	test   %eax,%eax
  10496c:	79 12                	jns    104980 <sys_chdir+0x30>
    return -1;
  }
  iunlock(ip);
  iput(proc->cwd);
  proc->cwd = ip;
  return 0;
  10496e:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104973:	83 c4 24             	add    $0x24,%esp
  104976:	5b                   	pop    %ebx
  104977:	5d                   	pop    %ebp
  104978:	c3                   	ret    
  104979:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
sys_chdir(void)
{
  char *path;
  struct inode *ip;

  if(argstr(0, &path) < 0 || (ip = namei(path)) == 0)
  104980:	8b 45 f4             	mov    -0xc(%ebp),%eax
  104983:	89 04 24             	mov    %eax,(%esp)
  104986:	e8 55 d6 ff ff       	call   101fe0 <namei>
  10498b:	85 c0                	test   %eax,%eax
  10498d:	89 c3                	mov    %eax,%ebx
  10498f:	74 dd                	je     10496e <sys_chdir+0x1e>
    return -1;
  ilock(ip);
  104991:	89 04 24             	mov    %eax,(%esp)
  104994:	e8 a7 d3 ff ff       	call   101d40 <ilock>
  if(ip->type != T_DIR){
  104999:	66 83 7b 10 01       	cmpw   $0x1,0x10(%ebx)
  10499e:	75 26                	jne    1049c6 <sys_chdir+0x76>
    iunlockput(ip);
    return -1;
  }
  iunlock(ip);
  1049a0:	89 1c 24             	mov    %ebx,(%esp)
  1049a3:	e8 58 cf ff ff       	call   101900 <iunlock>
  iput(proc->cwd);
  1049a8:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1049ae:	8b 40 68             	mov    0x68(%eax),%eax
  1049b1:	89 04 24             	mov    %eax,(%esp)
  1049b4:	e8 57 d0 ff ff       	call   101a10 <iput>
  proc->cwd = ip;
  1049b9:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1049bf:	89 58 68             	mov    %ebx,0x68(%eax)
  1049c2:	31 c0                	xor    %eax,%eax
  return 0;
  1049c4:	eb ad                	jmp    104973 <sys_chdir+0x23>

  if(argstr(0, &path) < 0 || (ip = namei(path)) == 0)
    return -1;
  ilock(ip);
  if(ip->type != T_DIR){
    iunlockput(ip);
  1049c6:	89 1c 24             	mov    %ebx,(%esp)
  1049c9:	e8 82 d2 ff ff       	call   101c50 <iunlockput>
  1049ce:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    return -1;
  1049d3:	eb 9e                	jmp    104973 <sys_chdir+0x23>
  1049d5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1049d9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001049e0 <create>:
  return 0;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
  1049e0:	55                   	push   %ebp
  1049e1:	89 e5                	mov    %esp,%ebp
  1049e3:	83 ec 58             	sub    $0x58,%esp
  1049e6:	89 4d c4             	mov    %ecx,-0x3c(%ebp)
  1049e9:	8b 4d 08             	mov    0x8(%ebp),%ecx
  1049ec:	89 75 f8             	mov    %esi,-0x8(%ebp)
  uint off;
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
  1049ef:	8d 75 d6             	lea    -0x2a(%ebp),%esi
  return 0;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
  1049f2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  uint off;
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
  1049f5:	31 db                	xor    %ebx,%ebx
  return 0;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
  1049f7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  1049fa:	89 d7                	mov    %edx,%edi
  1049fc:	89 4d c0             	mov    %ecx,-0x40(%ebp)
  uint off;
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
  1049ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  104a03:	89 04 24             	mov    %eax,(%esp)
  104a06:	e8 b5 d5 ff ff       	call   101fc0 <nameiparent>
  104a0b:	85 c0                	test   %eax,%eax
  104a0d:	74 47                	je     104a56 <create+0x76>
    return 0;
  ilock(dp);
  104a0f:	89 04 24             	mov    %eax,(%esp)
  104a12:	89 45 bc             	mov    %eax,-0x44(%ebp)
  104a15:	e8 26 d3 ff ff       	call   101d40 <ilock>

  if((ip = dirlookup(dp, name, &off)) != 0){
  104a1a:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104a1d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  104a20:	89 44 24 08          	mov    %eax,0x8(%esp)
  104a24:	89 74 24 04          	mov    %esi,0x4(%esp)
  104a28:	89 14 24             	mov    %edx,(%esp)
  104a2b:	e8 d0 cd ff ff       	call   101800 <dirlookup>
  104a30:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104a33:	85 c0                	test   %eax,%eax
  104a35:	89 c3                	mov    %eax,%ebx
  104a37:	74 3f                	je     104a78 <create+0x98>
    iunlockput(dp);
  104a39:	89 14 24             	mov    %edx,(%esp)
  104a3c:	e8 0f d2 ff ff       	call   101c50 <iunlockput>
    ilock(ip);
  104a41:	89 1c 24             	mov    %ebx,(%esp)
  104a44:	e8 f7 d2 ff ff       	call   101d40 <ilock>
    if(type == T_FILE && ip->type == T_FILE)
  104a49:	66 83 ff 02          	cmp    $0x2,%di
  104a4d:	75 19                	jne    104a68 <create+0x88>
  104a4f:	66 83 7b 10 02       	cmpw   $0x2,0x10(%ebx)
  104a54:	75 12                	jne    104a68 <create+0x88>
  if(dirlink(dp, name, ip->inum) < 0)
    panic("create: dirlink");

  iunlockput(dp);
  return ip;
}
  104a56:	89 d8                	mov    %ebx,%eax
  104a58:	8b 75 f8             	mov    -0x8(%ebp),%esi
  104a5b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  104a5e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  104a61:	89 ec                	mov    %ebp,%esp
  104a63:	5d                   	pop    %ebp
  104a64:	c3                   	ret    
  104a65:	8d 76 00             	lea    0x0(%esi),%esi
  if((ip = dirlookup(dp, name, &off)) != 0){
    iunlockput(dp);
    ilock(ip);
    if(type == T_FILE && ip->type == T_FILE)
      return ip;
    iunlockput(ip);
  104a68:	89 1c 24             	mov    %ebx,(%esp)
  104a6b:	31 db                	xor    %ebx,%ebx
  104a6d:	e8 de d1 ff ff       	call   101c50 <iunlockput>
    return 0;
  104a72:	eb e2                	jmp    104a56 <create+0x76>
  104a74:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  }

  if((ip = ialloc(dp->dev, type)) == 0)
  104a78:	0f bf c7             	movswl %di,%eax
  104a7b:	89 44 24 04          	mov    %eax,0x4(%esp)
  104a7f:	8b 02                	mov    (%edx),%eax
  104a81:	89 55 bc             	mov    %edx,-0x44(%ebp)
  104a84:	89 04 24             	mov    %eax,(%esp)
  104a87:	e8 e4 d1 ff ff       	call   101c70 <ialloc>
  104a8c:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104a8f:	85 c0                	test   %eax,%eax
  104a91:	89 c3                	mov    %eax,%ebx
  104a93:	0f 84 b7 00 00 00    	je     104b50 <create+0x170>
    panic("create: ialloc");

  ilock(ip);
  104a99:	89 55 bc             	mov    %edx,-0x44(%ebp)
  104a9c:	89 04 24             	mov    %eax,(%esp)
  104a9f:	e8 9c d2 ff ff       	call   101d40 <ilock>
  ip->major = major;
  104aa4:	0f b7 45 c4          	movzwl -0x3c(%ebp),%eax
  104aa8:	66 89 43 12          	mov    %ax,0x12(%ebx)
  ip->minor = minor;
  104aac:	0f b7 4d c0          	movzwl -0x40(%ebp),%ecx
  ip->nlink = 1;
  104ab0:	66 c7 43 16 01 00    	movw   $0x1,0x16(%ebx)
  if((ip = ialloc(dp->dev, type)) == 0)
    panic("create: ialloc");

  ilock(ip);
  ip->major = major;
  ip->minor = minor;
  104ab6:	66 89 4b 14          	mov    %cx,0x14(%ebx)
  ip->nlink = 1;
  iupdate(ip);
  104aba:	89 1c 24             	mov    %ebx,(%esp)
  104abd:	e8 3e cb ff ff       	call   101600 <iupdate>

  if(type == T_DIR){  // Create . and .. entries.
  104ac2:	66 83 ff 01          	cmp    $0x1,%di
  104ac6:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104ac9:	74 2d                	je     104af8 <create+0x118>
    // No ip->nlink++ for ".": avoid cyclic ref count.
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
      panic("create dots");
  }

  if(dirlink(dp, name, ip->inum) < 0)
  104acb:	8b 43 04             	mov    0x4(%ebx),%eax
  104ace:	89 14 24             	mov    %edx,(%esp)
  104ad1:	89 55 bc             	mov    %edx,-0x44(%ebp)
  104ad4:	89 74 24 04          	mov    %esi,0x4(%esp)
  104ad8:	89 44 24 08          	mov    %eax,0x8(%esp)
  104adc:	e8 7f d0 ff ff       	call   101b60 <dirlink>
  104ae1:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104ae4:	85 c0                	test   %eax,%eax
  104ae6:	78 74                	js     104b5c <create+0x17c>
    panic("create: dirlink");

  iunlockput(dp);
  104ae8:	89 14 24             	mov    %edx,(%esp)
  104aeb:	e8 60 d1 ff ff       	call   101c50 <iunlockput>
  return ip;
  104af0:	e9 61 ff ff ff       	jmp    104a56 <create+0x76>
  104af5:	8d 76 00             	lea    0x0(%esi),%esi
  ip->minor = minor;
  ip->nlink = 1;
  iupdate(ip);

  if(type == T_DIR){  // Create . and .. entries.
    dp->nlink++;  // for ".."
  104af8:	66 83 42 16 01       	addw   $0x1,0x16(%edx)
    iupdate(dp);
  104afd:	89 14 24             	mov    %edx,(%esp)
  104b00:	89 55 bc             	mov    %edx,-0x44(%ebp)
  104b03:	e8 f8 ca ff ff       	call   101600 <iupdate>
    // No ip->nlink++ for ".": avoid cyclic ref count.
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
  104b08:	8b 43 04             	mov    0x4(%ebx),%eax
  104b0b:	c7 44 24 04 10 73 10 	movl   $0x107310,0x4(%esp)
  104b12:	00 
  104b13:	89 1c 24             	mov    %ebx,(%esp)
  104b16:	89 44 24 08          	mov    %eax,0x8(%esp)
  104b1a:	e8 41 d0 ff ff       	call   101b60 <dirlink>
  104b1f:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104b22:	85 c0                	test   %eax,%eax
  104b24:	78 1e                	js     104b44 <create+0x164>
  104b26:	8b 42 04             	mov    0x4(%edx),%eax
  104b29:	c7 44 24 04 0f 73 10 	movl   $0x10730f,0x4(%esp)
  104b30:	00 
  104b31:	89 1c 24             	mov    %ebx,(%esp)
  104b34:	89 44 24 08          	mov    %eax,0x8(%esp)
  104b38:	e8 23 d0 ff ff       	call   101b60 <dirlink>
  104b3d:	8b 55 bc             	mov    -0x44(%ebp),%edx
  104b40:	85 c0                	test   %eax,%eax
  104b42:	79 87                	jns    104acb <create+0xeb>
      panic("create dots");
  104b44:	c7 04 24 12 73 10 00 	movl   $0x107312,(%esp)
  104b4b:	e8 10 bf ff ff       	call   100a60 <panic>
    iunlockput(ip);
    return 0;
  }

  if((ip = ialloc(dp->dev, type)) == 0)
    panic("create: ialloc");
  104b50:	c7 04 24 00 73 10 00 	movl   $0x107300,(%esp)
  104b57:	e8 04 bf ff ff       	call   100a60 <panic>
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
      panic("create dots");
  }

  if(dirlink(dp, name, ip->inum) < 0)
    panic("create: dirlink");
  104b5c:	c7 04 24 1e 73 10 00 	movl   $0x10731e,(%esp)
  104b63:	e8 f8 be ff ff       	call   100a60 <panic>
  104b68:	90                   	nop
  104b69:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00104b70 <sys_mknod>:
  return 0;
}

int
sys_mknod(void)
{
  104b70:	55                   	push   %ebp
  104b71:	89 e5                	mov    %esp,%ebp
  104b73:	83 ec 28             	sub    $0x28,%esp
  struct inode *ip;
  char *path;
  int len;
  int major, minor;
  
  if((len=argstr(0, &path)) < 0 ||
  104b76:	8d 45 f4             	lea    -0xc(%ebp),%eax
  104b79:	89 44 24 04          	mov    %eax,0x4(%esp)
  104b7d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104b84:	e8 07 fb ff ff       	call   104690 <argstr>
  104b89:	85 c0                	test   %eax,%eax
  104b8b:	79 0b                	jns    104b98 <sys_mknod+0x28>
     argint(1, &major) < 0 ||
     argint(2, &minor) < 0 ||
     (ip = create(path, T_DEV, major, minor)) == 0)
    return -1;
  iunlockput(ip);
  return 0;
  104b8d:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104b92:	c9                   	leave  
  104b93:	c3                   	ret    
  104b94:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *path;
  int len;
  int major, minor;
  
  if((len=argstr(0, &path)) < 0 ||
     argint(1, &major) < 0 ||
  104b98:	8d 45 f0             	lea    -0x10(%ebp),%eax
  104b9b:	89 44 24 04          	mov    %eax,0x4(%esp)
  104b9f:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  104ba6:	e8 55 fa ff ff       	call   104600 <argint>
  struct inode *ip;
  char *path;
  int len;
  int major, minor;
  
  if((len=argstr(0, &path)) < 0 ||
  104bab:	85 c0                	test   %eax,%eax
  104bad:	78 de                	js     104b8d <sys_mknod+0x1d>
     argint(1, &major) < 0 ||
     argint(2, &minor) < 0 ||
  104baf:	8d 45 ec             	lea    -0x14(%ebp),%eax
  104bb2:	89 44 24 04          	mov    %eax,0x4(%esp)
  104bb6:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
  104bbd:	e8 3e fa ff ff       	call   104600 <argint>
  struct inode *ip;
  char *path;
  int len;
  int major, minor;
  
  if((len=argstr(0, &path)) < 0 ||
  104bc2:	85 c0                	test   %eax,%eax
  104bc4:	78 c7                	js     104b8d <sys_mknod+0x1d>
     argint(1, &major) < 0 ||
     argint(2, &minor) < 0 ||
     (ip = create(path, T_DEV, major, minor)) == 0)
  104bc6:	0f bf 45 ec          	movswl -0x14(%ebp),%eax
  104bca:	ba 03 00 00 00       	mov    $0x3,%edx
  104bcf:	0f bf 4d f0          	movswl -0x10(%ebp),%ecx
  104bd3:	89 04 24             	mov    %eax,(%esp)
  104bd6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  104bd9:	e8 02 fe ff ff       	call   1049e0 <create>
  struct inode *ip;
  char *path;
  int len;
  int major, minor;
  
  if((len=argstr(0, &path)) < 0 ||
  104bde:	85 c0                	test   %eax,%eax
  104be0:	74 ab                	je     104b8d <sys_mknod+0x1d>
     argint(1, &major) < 0 ||
     argint(2, &minor) < 0 ||
     (ip = create(path, T_DEV, major, minor)) == 0)
    return -1;
  iunlockput(ip);
  104be2:	89 04 24             	mov    %eax,(%esp)
  104be5:	e8 66 d0 ff ff       	call   101c50 <iunlockput>
  104bea:	31 c0                	xor    %eax,%eax
  return 0;
}
  104bec:	c9                   	leave  
  104bed:	c3                   	ret    
  104bee:	66 90                	xchg   %ax,%ax

00104bf0 <sys_mkdir>:
  return fd;
}

int
sys_mkdir(void)
{
  104bf0:	55                   	push   %ebp
  104bf1:	89 e5                	mov    %esp,%ebp
  104bf3:	83 ec 28             	sub    $0x28,%esp
  char *path;
  struct inode *ip;

  if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0)
  104bf6:	8d 45 f4             	lea    -0xc(%ebp),%eax
  104bf9:	89 44 24 04          	mov    %eax,0x4(%esp)
  104bfd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104c04:	e8 87 fa ff ff       	call   104690 <argstr>
  104c09:	85 c0                	test   %eax,%eax
  104c0b:	79 0b                	jns    104c18 <sys_mkdir+0x28>
    return -1;
  iunlockput(ip);
  return 0;
  104c0d:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104c12:	c9                   	leave  
  104c13:	c3                   	ret    
  104c14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
sys_mkdir(void)
{
  char *path;
  struct inode *ip;

  if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0)
  104c18:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104c1f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  104c22:	31 c9                	xor    %ecx,%ecx
  104c24:	ba 01 00 00 00       	mov    $0x1,%edx
  104c29:	e8 b2 fd ff ff       	call   1049e0 <create>
  104c2e:	85 c0                	test   %eax,%eax
  104c30:	74 db                	je     104c0d <sys_mkdir+0x1d>
    return -1;
  iunlockput(ip);
  104c32:	89 04 24             	mov    %eax,(%esp)
  104c35:	e8 16 d0 ff ff       	call   101c50 <iunlockput>
  104c3a:	31 c0                	xor    %eax,%eax
  return 0;
}
  104c3c:	c9                   	leave  
  104c3d:	c3                   	ret    
  104c3e:	66 90                	xchg   %ax,%ax

00104c40 <sys_link>:
}

// Create the path new as a link to the same inode as old.
int
sys_link(void)
{
  104c40:	55                   	push   %ebp
  104c41:	89 e5                	mov    %esp,%ebp
  104c43:	83 ec 48             	sub    $0x48,%esp
  char name[DIRSIZ], *new, *old;
  struct inode *dp, *ip;

  if(argstr(0, &old) < 0 || argstr(1, &new) < 0)
  104c46:	8d 45 e0             	lea    -0x20(%ebp),%eax
}

// Create the path new as a link to the same inode as old.
int
sys_link(void)
{
  104c49:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  104c4c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  104c4f:	89 7d fc             	mov    %edi,-0x4(%ebp)
  char name[DIRSIZ], *new, *old;
  struct inode *dp, *ip;

  if(argstr(0, &old) < 0 || argstr(1, &new) < 0)
  104c52:	89 44 24 04          	mov    %eax,0x4(%esp)
  104c56:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104c5d:	e8 2e fa ff ff       	call   104690 <argstr>
  104c62:	85 c0                	test   %eax,%eax
  104c64:	79 12                	jns    104c78 <sys_link+0x38>
bad:
  ilock(ip);
  ip->nlink--;
  iupdate(ip);
  iunlockput(ip);
  return -1;
  104c66:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104c6b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  104c6e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  104c71:	8b 7d fc             	mov    -0x4(%ebp),%edi
  104c74:	89 ec                	mov    %ebp,%esp
  104c76:	5d                   	pop    %ebp
  104c77:	c3                   	ret    
sys_link(void)
{
  char name[DIRSIZ], *new, *old;
  struct inode *dp, *ip;

  if(argstr(0, &old) < 0 || argstr(1, &new) < 0)
  104c78:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  104c7b:	89 44 24 04          	mov    %eax,0x4(%esp)
  104c7f:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  104c86:	e8 05 fa ff ff       	call   104690 <argstr>
  104c8b:	85 c0                	test   %eax,%eax
  104c8d:	78 d7                	js     104c66 <sys_link+0x26>
    return -1;
  if((ip = namei(old)) == 0)
  104c8f:	8b 45 e0             	mov    -0x20(%ebp),%eax
  104c92:	89 04 24             	mov    %eax,(%esp)
  104c95:	e8 46 d3 ff ff       	call   101fe0 <namei>
  104c9a:	85 c0                	test   %eax,%eax
  104c9c:	89 c3                	mov    %eax,%ebx
  104c9e:	74 c6                	je     104c66 <sys_link+0x26>
    return -1;
  ilock(ip);
  104ca0:	89 04 24             	mov    %eax,(%esp)
  104ca3:	e8 98 d0 ff ff       	call   101d40 <ilock>
  if(ip->type == T_DIR){
  104ca8:	66 83 7b 10 01       	cmpw   $0x1,0x10(%ebx)
  104cad:	0f 84 86 00 00 00    	je     104d39 <sys_link+0xf9>
    iunlockput(ip);
    return -1;
  }
  ip->nlink++;
  104cb3:	66 83 43 16 01       	addw   $0x1,0x16(%ebx)
  iupdate(ip);
  iunlock(ip);

  if((dp = nameiparent(new, name)) == 0)
  104cb8:	8d 7d d2             	lea    -0x2e(%ebp),%edi
  if(ip->type == T_DIR){
    iunlockput(ip);
    return -1;
  }
  ip->nlink++;
  iupdate(ip);
  104cbb:	89 1c 24             	mov    %ebx,(%esp)
  104cbe:	e8 3d c9 ff ff       	call   101600 <iupdate>
  iunlock(ip);
  104cc3:	89 1c 24             	mov    %ebx,(%esp)
  104cc6:	e8 35 cc ff ff       	call   101900 <iunlock>

  if((dp = nameiparent(new, name)) == 0)
  104ccb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  104cce:	89 7c 24 04          	mov    %edi,0x4(%esp)
  104cd2:	89 04 24             	mov    %eax,(%esp)
  104cd5:	e8 e6 d2 ff ff       	call   101fc0 <nameiparent>
  104cda:	85 c0                	test   %eax,%eax
  104cdc:	89 c6                	mov    %eax,%esi
  104cde:	74 44                	je     104d24 <sys_link+0xe4>
    goto bad;
  ilock(dp);
  104ce0:	89 04 24             	mov    %eax,(%esp)
  104ce3:	e8 58 d0 ff ff       	call   101d40 <ilock>
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
  104ce8:	8b 06                	mov    (%esi),%eax
  104cea:	3b 03                	cmp    (%ebx),%eax
  104cec:	75 2e                	jne    104d1c <sys_link+0xdc>
  104cee:	8b 43 04             	mov    0x4(%ebx),%eax
  104cf1:	89 7c 24 04          	mov    %edi,0x4(%esp)
  104cf5:	89 34 24             	mov    %esi,(%esp)
  104cf8:	89 44 24 08          	mov    %eax,0x8(%esp)
  104cfc:	e8 5f ce ff ff       	call   101b60 <dirlink>
  104d01:	85 c0                	test   %eax,%eax
  104d03:	78 17                	js     104d1c <sys_link+0xdc>
    iunlockput(dp);
    goto bad;
  }
  iunlockput(dp);
  104d05:	89 34 24             	mov    %esi,(%esp)
  104d08:	e8 43 cf ff ff       	call   101c50 <iunlockput>
  iput(ip);
  104d0d:	89 1c 24             	mov    %ebx,(%esp)
  104d10:	e8 fb cc ff ff       	call   101a10 <iput>
  104d15:	31 c0                	xor    %eax,%eax
  return 0;
  104d17:	e9 4f ff ff ff       	jmp    104c6b <sys_link+0x2b>

  if((dp = nameiparent(new, name)) == 0)
    goto bad;
  ilock(dp);
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
    iunlockput(dp);
  104d1c:	89 34 24             	mov    %esi,(%esp)
  104d1f:	e8 2c cf ff ff       	call   101c50 <iunlockput>
  iunlockput(dp);
  iput(ip);
  return 0;

bad:
  ilock(ip);
  104d24:	89 1c 24             	mov    %ebx,(%esp)
  104d27:	e8 14 d0 ff ff       	call   101d40 <ilock>
  ip->nlink--;
  104d2c:	66 83 6b 16 01       	subw   $0x1,0x16(%ebx)
  iupdate(ip);
  104d31:	89 1c 24             	mov    %ebx,(%esp)
  104d34:	e8 c7 c8 ff ff       	call   101600 <iupdate>
  iunlockput(ip);
  104d39:	89 1c 24             	mov    %ebx,(%esp)
  104d3c:	e8 0f cf ff ff       	call   101c50 <iunlockput>
  104d41:	83 c8 ff             	or     $0xffffffff,%eax
  return -1;
  104d44:	e9 22 ff ff ff       	jmp    104c6b <sys_link+0x2b>
  104d49:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00104d50 <sys_open>:
  return ip;
}

int
sys_open(void)
{
  104d50:	55                   	push   %ebp
  104d51:	89 e5                	mov    %esp,%ebp
  104d53:	83 ec 38             	sub    $0x38,%esp
  char *path;
  int fd, omode;
  struct file *f;
  struct inode *ip;

  if(argstr(0, &path) < 0 || argint(1, &omode) < 0)
  104d56:	8d 45 f4             	lea    -0xc(%ebp),%eax
  return ip;
}

int
sys_open(void)
{
  104d59:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  104d5c:	89 75 fc             	mov    %esi,-0x4(%ebp)
  char *path;
  int fd, omode;
  struct file *f;
  struct inode *ip;

  if(argstr(0, &path) < 0 || argint(1, &omode) < 0)
  104d5f:	89 44 24 04          	mov    %eax,0x4(%esp)
  104d63:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104d6a:	e8 21 f9 ff ff       	call   104690 <argstr>
  104d6f:	85 c0                	test   %eax,%eax
  104d71:	79 15                	jns    104d88 <sys_open+0x38>

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    if(f)
      fileclose(f);
    iunlockput(ip);
    return -1;
  104d73:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  f->ip = ip;
  f->off = 0;
  f->readable = !(omode & O_WRONLY);
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
  return fd;
}
  104d78:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  104d7b:	8b 75 fc             	mov    -0x4(%ebp),%esi
  104d7e:	89 ec                	mov    %ebp,%esp
  104d80:	5d                   	pop    %ebp
  104d81:	c3                   	ret    
  104d82:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  char *path;
  int fd, omode;
  struct file *f;
  struct inode *ip;

  if(argstr(0, &path) < 0 || argint(1, &omode) < 0)
  104d88:	8d 45 f0             	lea    -0x10(%ebp),%eax
  104d8b:	89 44 24 04          	mov    %eax,0x4(%esp)
  104d8f:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  104d96:	e8 65 f8 ff ff       	call   104600 <argint>
  104d9b:	85 c0                	test   %eax,%eax
  104d9d:	78 d4                	js     104d73 <sys_open+0x23>
    return -1;
  if(omode & O_CREATE){
  104d9f:	f6 45 f1 02          	testb  $0x2,-0xf(%ebp)
  104da3:	74 63                	je     104e08 <sys_open+0xb8>
    if((ip = create(path, T_FILE, 0, 0)) == 0)
  104da5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  104da8:	31 c9                	xor    %ecx,%ecx
  104daa:	ba 02 00 00 00       	mov    $0x2,%edx
  104daf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104db6:	e8 25 fc ff ff       	call   1049e0 <create>
  104dbb:	85 c0                	test   %eax,%eax
  104dbd:	89 c3                	mov    %eax,%ebx
  104dbf:	74 b2                	je     104d73 <sys_open+0x23>
      iunlockput(ip);
      return -1;
    }
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
  104dc1:	e8 ca c2 ff ff       	call   101090 <filealloc>
  104dc6:	85 c0                	test   %eax,%eax
  104dc8:	89 c6                	mov    %eax,%esi
  104dca:	74 24                	je     104df0 <sys_open+0xa0>
  104dcc:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  104dd3:	31 c0                	xor    %eax,%eax
  104dd5:	8d 76 00             	lea    0x0(%esi),%esi
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd] == 0){
  104dd8:	8b 4c 82 28          	mov    0x28(%edx,%eax,4),%ecx
  104ddc:	85 c9                	test   %ecx,%ecx
  104dde:	74 58                	je     104e38 <sys_open+0xe8>
static int
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
  104de0:	83 c0 01             	add    $0x1,%eax
  104de3:	83 f8 10             	cmp    $0x10,%eax
  104de6:	75 f0                	jne    104dd8 <sys_open+0x88>
    }
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    if(f)
      fileclose(f);
  104de8:	89 34 24             	mov    %esi,(%esp)
  104deb:	e8 20 c3 ff ff       	call   101110 <fileclose>
    iunlockput(ip);
  104df0:	89 1c 24             	mov    %ebx,(%esp)
  104df3:	e8 58 ce ff ff       	call   101c50 <iunlockput>
  104df8:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    return -1;
  104dfd:	e9 76 ff ff ff       	jmp    104d78 <sys_open+0x28>
  104e02:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    return -1;
  if(omode & O_CREATE){
    if((ip = create(path, T_FILE, 0, 0)) == 0)
      return -1;
  } else {
    if((ip = namei(path)) == 0)
  104e08:	8b 45 f4             	mov    -0xc(%ebp),%eax
  104e0b:	89 04 24             	mov    %eax,(%esp)
  104e0e:	e8 cd d1 ff ff       	call   101fe0 <namei>
  104e13:	85 c0                	test   %eax,%eax
  104e15:	89 c3                	mov    %eax,%ebx
  104e17:	0f 84 56 ff ff ff    	je     104d73 <sys_open+0x23>
      return -1;
    ilock(ip);
  104e1d:	89 04 24             	mov    %eax,(%esp)
  104e20:	e8 1b cf ff ff       	call   101d40 <ilock>
    if(ip->type == T_DIR && omode != O_RDONLY){
  104e25:	66 83 7b 10 01       	cmpw   $0x1,0x10(%ebx)
  104e2a:	75 95                	jne    104dc1 <sys_open+0x71>
  104e2c:	8b 75 f0             	mov    -0x10(%ebp),%esi
  104e2f:	85 f6                	test   %esi,%esi
  104e31:	74 8e                	je     104dc1 <sys_open+0x71>
  104e33:	eb bb                	jmp    104df0 <sys_open+0xa0>
  104e35:	8d 76 00             	lea    0x0(%esi),%esi
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
    if(proc->ofile[fd] == 0){
      proc->ofile[fd] = f;
  104e38:	89 74 82 28          	mov    %esi,0x28(%edx,%eax,4)
    if(f)
      fileclose(f);
    iunlockput(ip);
    return -1;
  }
  iunlock(ip);
  104e3c:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  104e3f:	89 1c 24             	mov    %ebx,(%esp)
  104e42:	e8 b9 ca ff ff       	call   101900 <iunlock>

  f->type = FD_INODE;
  104e47:	c7 06 02 00 00 00    	movl   $0x2,(%esi)
  f->ip = ip;
  104e4d:	89 5e 10             	mov    %ebx,0x10(%esi)
  f->off = 0;
  104e50:	c7 46 14 00 00 00 00 	movl   $0x0,0x14(%esi)
  f->readable = !(omode & O_WRONLY);
  104e57:	8b 55 f0             	mov    -0x10(%ebp),%edx
  104e5a:	83 f2 01             	xor    $0x1,%edx
  104e5d:	83 e2 01             	and    $0x1,%edx
  104e60:	88 56 08             	mov    %dl,0x8(%esi)
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
  104e63:	f6 45 f0 03          	testb  $0x3,-0x10(%ebp)
  104e67:	0f 95 46 09          	setne  0x9(%esi)
  return fd;
  104e6b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  104e6e:	e9 05 ff ff ff       	jmp    104d78 <sys_open+0x28>
  104e73:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  104e79:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00104e80 <sys_unlink>:
  return 1;
}

int
sys_unlink(void)
{
  104e80:	55                   	push   %ebp
  104e81:	89 e5                	mov    %esp,%ebp
  104e83:	83 ec 78             	sub    $0x78,%esp
  struct inode *ip, *dp;
  struct dirent de;
  char name[DIRSIZ], *path;
  uint off;

  if(argstr(0, &path) < 0)
  104e86:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  return 1;
}

int
sys_unlink(void)
{
  104e89:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  104e8c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  104e8f:	89 7d fc             	mov    %edi,-0x4(%ebp)
  struct inode *ip, *dp;
  struct dirent de;
  char name[DIRSIZ], *path;
  uint off;

  if(argstr(0, &path) < 0)
  104e92:	89 44 24 04          	mov    %eax,0x4(%esp)
  104e96:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  104e9d:	e8 ee f7 ff ff       	call   104690 <argstr>
  104ea2:	85 c0                	test   %eax,%eax
  104ea4:	79 12                	jns    104eb8 <sys_unlink+0x38>
  iunlockput(dp);

  ip->nlink--;
  iupdate(ip);
  iunlockput(ip);
  return 0;
  104ea6:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  104eab:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  104eae:	8b 75 f8             	mov    -0x8(%ebp),%esi
  104eb1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  104eb4:	89 ec                	mov    %ebp,%esp
  104eb6:	5d                   	pop    %ebp
  104eb7:	c3                   	ret    
  char name[DIRSIZ], *path;
  uint off;

  if(argstr(0, &path) < 0)
    return -1;
  if((dp = nameiparent(path, name)) == 0)
  104eb8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  104ebb:	8d 5d d2             	lea    -0x2e(%ebp),%ebx
  104ebe:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  104ec2:	89 04 24             	mov    %eax,(%esp)
  104ec5:	e8 f6 d0 ff ff       	call   101fc0 <nameiparent>
  104eca:	85 c0                	test   %eax,%eax
  104ecc:	89 45 a4             	mov    %eax,-0x5c(%ebp)
  104ecf:	74 d5                	je     104ea6 <sys_unlink+0x26>
    return -1;
  ilock(dp);
  104ed1:	89 04 24             	mov    %eax,(%esp)
  104ed4:	e8 67 ce ff ff       	call   101d40 <ilock>

  // Cannot unlink "." or "..".
  if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0){
  104ed9:	c7 44 24 04 10 73 10 	movl   $0x107310,0x4(%esp)
  104ee0:	00 
  104ee1:	89 1c 24             	mov    %ebx,(%esp)
  104ee4:	e8 e7 c8 ff ff       	call   1017d0 <namecmp>
  104ee9:	85 c0                	test   %eax,%eax
  104eeb:	0f 84 a4 00 00 00    	je     104f95 <sys_unlink+0x115>
  104ef1:	c7 44 24 04 0f 73 10 	movl   $0x10730f,0x4(%esp)
  104ef8:	00 
  104ef9:	89 1c 24             	mov    %ebx,(%esp)
  104efc:	e8 cf c8 ff ff       	call   1017d0 <namecmp>
  104f01:	85 c0                	test   %eax,%eax
  104f03:	0f 84 8c 00 00 00    	je     104f95 <sys_unlink+0x115>
    iunlockput(dp);
    return -1;
  }

  if((ip = dirlookup(dp, name, &off)) == 0){
  104f09:	8d 45 e0             	lea    -0x20(%ebp),%eax
  104f0c:	89 44 24 08          	mov    %eax,0x8(%esp)
  104f10:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  104f13:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  104f17:	89 04 24             	mov    %eax,(%esp)
  104f1a:	e8 e1 c8 ff ff       	call   101800 <dirlookup>
  104f1f:	85 c0                	test   %eax,%eax
  104f21:	89 c6                	mov    %eax,%esi
  104f23:	74 70                	je     104f95 <sys_unlink+0x115>
    iunlockput(dp);
    return -1;
  }
  ilock(ip);
  104f25:	89 04 24             	mov    %eax,(%esp)
  104f28:	e8 13 ce ff ff       	call   101d40 <ilock>

  if(ip->nlink < 1)
  104f2d:	66 83 7e 16 00       	cmpw   $0x0,0x16(%esi)
  104f32:	0f 8e 0e 01 00 00    	jle    105046 <sys_unlink+0x1c6>
    panic("unlink: nlink < 1");
  if(ip->type == T_DIR && !isdirempty(ip)){
  104f38:	66 83 7e 10 01       	cmpw   $0x1,0x10(%esi)
  104f3d:	75 71                	jne    104fb0 <sys_unlink+0x130>
isdirempty(struct inode *dp)
{
  int off;
  struct dirent de;

  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
  104f3f:	83 7e 18 20          	cmpl   $0x20,0x18(%esi)
  104f43:	76 6b                	jbe    104fb0 <sys_unlink+0x130>
  104f45:	8d 7d b2             	lea    -0x4e(%ebp),%edi
  104f48:	bb 20 00 00 00       	mov    $0x20,%ebx
  104f4d:	8d 76 00             	lea    0x0(%esi),%esi
  104f50:	eb 0e                	jmp    104f60 <sys_unlink+0xe0>
  104f52:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  104f58:	83 c3 10             	add    $0x10,%ebx
  104f5b:	3b 5e 18             	cmp    0x18(%esi),%ebx
  104f5e:	73 50                	jae    104fb0 <sys_unlink+0x130>
    if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
  104f60:	c7 44 24 0c 10 00 00 	movl   $0x10,0xc(%esp)
  104f67:	00 
  104f68:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  104f6c:	89 7c 24 04          	mov    %edi,0x4(%esp)
  104f70:	89 34 24             	mov    %esi,(%esp)
  104f73:	e8 88 c5 ff ff       	call   101500 <readi>
  104f78:	83 f8 10             	cmp    $0x10,%eax
  104f7b:	0f 85 ad 00 00 00    	jne    10502e <sys_unlink+0x1ae>
      panic("isdirempty: readi");
    if(de.inum != 0)
  104f81:	66 83 7d b2 00       	cmpw   $0x0,-0x4e(%ebp)
  104f86:	74 d0                	je     104f58 <sys_unlink+0xd8>
  ilock(ip);

  if(ip->nlink < 1)
    panic("unlink: nlink < 1");
  if(ip->type == T_DIR && !isdirempty(ip)){
    iunlockput(ip);
  104f88:	89 34 24             	mov    %esi,(%esp)
  104f8b:	90                   	nop
  104f8c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  104f90:	e8 bb cc ff ff       	call   101c50 <iunlockput>
    iunlockput(dp);
  104f95:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  104f98:	89 04 24             	mov    %eax,(%esp)
  104f9b:	e8 b0 cc ff ff       	call   101c50 <iunlockput>
  104fa0:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    return -1;
  104fa5:	e9 01 ff ff ff       	jmp    104eab <sys_unlink+0x2b>
  104faa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  }

  memset(&de, 0, sizeof(de));
  104fb0:	8d 5d c2             	lea    -0x3e(%ebp),%ebx
  104fb3:	c7 44 24 08 10 00 00 	movl   $0x10,0x8(%esp)
  104fba:	00 
  104fbb:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  104fc2:	00 
  104fc3:	89 1c 24             	mov    %ebx,(%esp)
  104fc6:	e8 95 f3 ff ff       	call   104360 <memset>
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
  104fcb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  104fce:	c7 44 24 0c 10 00 00 	movl   $0x10,0xc(%esp)
  104fd5:	00 
  104fd6:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  104fda:	89 44 24 08          	mov    %eax,0x8(%esp)
  104fde:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  104fe1:	89 04 24             	mov    %eax,(%esp)
  104fe4:	e8 a7 c6 ff ff       	call   101690 <writei>
  104fe9:	83 f8 10             	cmp    $0x10,%eax
  104fec:	75 4c                	jne    10503a <sys_unlink+0x1ba>
    panic("unlink: writei");
  if(ip->type == T_DIR){
  104fee:	66 83 7e 10 01       	cmpw   $0x1,0x10(%esi)
  104ff3:	74 27                	je     10501c <sys_unlink+0x19c>
    dp->nlink--;
    iupdate(dp);
  }
  iunlockput(dp);
  104ff5:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  104ff8:	89 04 24             	mov    %eax,(%esp)
  104ffb:	e8 50 cc ff ff       	call   101c50 <iunlockput>

  ip->nlink--;
  105000:	66 83 6e 16 01       	subw   $0x1,0x16(%esi)
  iupdate(ip);
  105005:	89 34 24             	mov    %esi,(%esp)
  105008:	e8 f3 c5 ff ff       	call   101600 <iupdate>
  iunlockput(ip);
  10500d:	89 34 24             	mov    %esi,(%esp)
  105010:	e8 3b cc ff ff       	call   101c50 <iunlockput>
  105015:	31 c0                	xor    %eax,%eax
  return 0;
  105017:	e9 8f fe ff ff       	jmp    104eab <sys_unlink+0x2b>

  memset(&de, 0, sizeof(de));
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
    panic("unlink: writei");
  if(ip->type == T_DIR){
    dp->nlink--;
  10501c:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  10501f:	66 83 68 16 01       	subw   $0x1,0x16(%eax)
    iupdate(dp);
  105024:	89 04 24             	mov    %eax,(%esp)
  105027:	e8 d4 c5 ff ff       	call   101600 <iupdate>
  10502c:	eb c7                	jmp    104ff5 <sys_unlink+0x175>
  int off;
  struct dirent de;

  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
      panic("isdirempty: readi");
  10502e:	c7 04 24 40 73 10 00 	movl   $0x107340,(%esp)
  105035:	e8 26 ba ff ff       	call   100a60 <panic>
    return -1;
  }

  memset(&de, 0, sizeof(de));
  if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
    panic("unlink: writei");
  10503a:	c7 04 24 52 73 10 00 	movl   $0x107352,(%esp)
  105041:	e8 1a ba ff ff       	call   100a60 <panic>
    return -1;
  }
  ilock(ip);

  if(ip->nlink < 1)
    panic("unlink: nlink < 1");
  105046:	c7 04 24 2e 73 10 00 	movl   $0x10732e,(%esp)
  10504d:	e8 0e ba ff ff       	call   100a60 <panic>
  105052:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  105059:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00105060 <T.67>:
#include "fcntl.h"

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
  105060:	55                   	push   %ebp
  105061:	89 e5                	mov    %esp,%ebp
  105063:	83 ec 28             	sub    $0x28,%esp
  105066:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  105069:	89 c3                	mov    %eax,%ebx
{
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
  10506b:	8d 45 f4             	lea    -0xc(%ebp),%eax
#include "fcntl.h"

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
  10506e:	89 75 fc             	mov    %esi,-0x4(%ebp)
  105071:	89 d6                	mov    %edx,%esi
{
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
  105073:	89 44 24 04          	mov    %eax,0x4(%esp)
  105077:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  10507e:	e8 7d f5 ff ff       	call   104600 <argint>
  105083:	85 c0                	test   %eax,%eax
  105085:	79 11                	jns    105098 <T.67+0x38>
  if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0)
    return -1;
  if(pfd)
    *pfd = fd;
  if(pf)
    *pf = f;
  105087:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  return 0;
}
  10508c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  10508f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  105092:	89 ec                	mov    %ebp,%esp
  105094:	5d                   	pop    %ebp
  105095:	c3                   	ret    
  105096:	66 90                	xchg   %ax,%ax
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0)
  105098:	8b 45 f4             	mov    -0xc(%ebp),%eax
  10509b:	83 f8 0f             	cmp    $0xf,%eax
  10509e:	77 e7                	ja     105087 <T.67+0x27>
  1050a0:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  1050a7:	8b 54 82 28          	mov    0x28(%edx,%eax,4),%edx
  1050ab:	85 d2                	test   %edx,%edx
  1050ad:	74 d8                	je     105087 <T.67+0x27>
    return -1;
  if(pfd)
  1050af:	85 db                	test   %ebx,%ebx
  1050b1:	74 02                	je     1050b5 <T.67+0x55>
    *pfd = fd;
  1050b3:	89 03                	mov    %eax,(%ebx)
  if(pf)
  1050b5:	31 c0                	xor    %eax,%eax
  1050b7:	85 f6                	test   %esi,%esi
  1050b9:	74 d1                	je     10508c <T.67+0x2c>
    *pf = f;
  1050bb:	89 16                	mov    %edx,(%esi)
  1050bd:	eb cd                	jmp    10508c <T.67+0x2c>
  1050bf:	90                   	nop

001050c0 <sys_dup>:
  return -1;
}

int
sys_dup(void)
{
  1050c0:	55                   	push   %ebp
  struct file *f;
  int fd;
  
  if(argfd(0, 0, &f) < 0)
  1050c1:	31 c0                	xor    %eax,%eax
  return -1;
}

int
sys_dup(void)
{
  1050c3:	89 e5                	mov    %esp,%ebp
  1050c5:	53                   	push   %ebx
  1050c6:	83 ec 24             	sub    $0x24,%esp
  struct file *f;
  int fd;
  
  if(argfd(0, 0, &f) < 0)
  1050c9:	8d 55 f4             	lea    -0xc(%ebp),%edx
  1050cc:	e8 8f ff ff ff       	call   105060 <T.67>
  1050d1:	85 c0                	test   %eax,%eax
  1050d3:	79 13                	jns    1050e8 <sys_dup+0x28>
static int
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
  1050d5:	bb ff ff ff ff       	mov    $0xffffffff,%ebx
    return -1;
  if((fd=fdalloc(f)) < 0)
    return -1;
  filedup(f);
  return fd;
}
  1050da:	89 d8                	mov    %ebx,%eax
  1050dc:	83 c4 24             	add    $0x24,%esp
  1050df:	5b                   	pop    %ebx
  1050e0:	5d                   	pop    %ebp
  1050e1:	c3                   	ret    
  1050e2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  struct file *f;
  int fd;
  
  if(argfd(0, 0, &f) < 0)
    return -1;
  if((fd=fdalloc(f)) < 0)
  1050e8:	8b 55 f4             	mov    -0xc(%ebp),%edx
  1050eb:	31 db                	xor    %ebx,%ebx
  1050ed:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1050f3:	eb 0b                	jmp    105100 <sys_dup+0x40>
  1050f5:	8d 76 00             	lea    0x0(%esi),%esi
static int
fdalloc(struct file *f)
{
  int fd;

  for(fd = 0; fd < NOFILE; fd++){
  1050f8:	83 c3 01             	add    $0x1,%ebx
  1050fb:	83 fb 10             	cmp    $0x10,%ebx
  1050fe:	74 d5                	je     1050d5 <sys_dup+0x15>
    if(proc->ofile[fd] == 0){
  105100:	8b 4c 98 28          	mov    0x28(%eax,%ebx,4),%ecx
  105104:	85 c9                	test   %ecx,%ecx
  105106:	75 f0                	jne    1050f8 <sys_dup+0x38>
      proc->ofile[fd] = f;
  105108:	89 54 98 28          	mov    %edx,0x28(%eax,%ebx,4)
  
  if(argfd(0, 0, &f) < 0)
    return -1;
  if((fd=fdalloc(f)) < 0)
    return -1;
  filedup(f);
  10510c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  10510f:	89 04 24             	mov    %eax,(%esp)
  105112:	e8 29 bf ff ff       	call   101040 <filedup>
  return fd;
  105117:	eb c1                	jmp    1050da <sys_dup+0x1a>
  105119:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00105120 <sys_read>:
}

int
sys_read(void)
{
  105120:	55                   	push   %ebp
  struct file *f;
  int n;
  char *p;

  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
  105121:	31 c0                	xor    %eax,%eax
  return fd;
}

int
sys_read(void)
{
  105123:	89 e5                	mov    %esp,%ebp
  105125:	83 ec 28             	sub    $0x28,%esp
  struct file *f;
  int n;
  char *p;

  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
  105128:	8d 55 f4             	lea    -0xc(%ebp),%edx
  10512b:	e8 30 ff ff ff       	call   105060 <T.67>
  105130:	85 c0                	test   %eax,%eax
  105132:	79 0c                	jns    105140 <sys_read+0x20>
    return -1;
  return fileread(f, p, n);
  105134:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  105139:	c9                   	leave  
  10513a:	c3                   	ret    
  10513b:	90                   	nop
  10513c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
  struct file *f;
  int n;
  char *p;

  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
  105140:	8d 45 f0             	lea    -0x10(%ebp),%eax
  105143:	89 44 24 04          	mov    %eax,0x4(%esp)
  105147:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
  10514e:	e8 ad f4 ff ff       	call   104600 <argint>
  105153:	85 c0                	test   %eax,%eax
  105155:	78 dd                	js     105134 <sys_read+0x14>
  105157:	8b 45 f0             	mov    -0x10(%ebp),%eax
  10515a:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  105161:	89 44 24 08          	mov    %eax,0x8(%esp)
  105165:	8d 45 ec             	lea    -0x14(%ebp),%eax
  105168:	89 44 24 04          	mov    %eax,0x4(%esp)
  10516c:	e8 cf f4 ff ff       	call   104640 <argptr>
  105171:	85 c0                	test   %eax,%eax
  105173:	78 bf                	js     105134 <sys_read+0x14>
    return -1;
  return fileread(f, p, n);
  105175:	8b 45 f0             	mov    -0x10(%ebp),%eax
  105178:	89 44 24 08          	mov    %eax,0x8(%esp)
  10517c:	8b 45 ec             	mov    -0x14(%ebp),%eax
  10517f:	89 44 24 04          	mov    %eax,0x4(%esp)
  105183:	8b 45 f4             	mov    -0xc(%ebp),%eax
  105186:	89 04 24             	mov    %eax,(%esp)
  105189:	e8 b2 bd ff ff       	call   100f40 <fileread>
}
  10518e:	c9                   	leave  
  10518f:	c3                   	ret    

00105190 <sys_write>:

int
sys_write(void)
{
  105190:	55                   	push   %ebp
  struct file *f;
  int n;
  char *p;

  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
  105191:	31 c0                	xor    %eax,%eax
  return fileread(f, p, n);
}

int
sys_write(void)
{
  105193:	89 e5                	mov    %esp,%ebp
  105195:	83 ec 28             	sub    $0x28,%esp
  struct file *f;
  int n;
  char *p;

  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
  105198:	8d 55 f4             	lea    -0xc(%ebp),%edx
  10519b:	e8 c0 fe ff ff       	call   105060 <T.67>
  1051a0:	85 c0                	test   %eax,%eax
  1051a2:	79 0c                	jns    1051b0 <sys_write+0x20>
    return -1;
  return filewrite(f, p, n);
  1051a4:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  1051a9:	c9                   	leave  
  1051aa:	c3                   	ret    
  1051ab:	90                   	nop
  1051ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
  struct file *f;
  int n;
  char *p;

  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
  1051b0:	8d 45 f0             	lea    -0x10(%ebp),%eax
  1051b3:	89 44 24 04          	mov    %eax,0x4(%esp)
  1051b7:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
  1051be:	e8 3d f4 ff ff       	call   104600 <argint>
  1051c3:	85 c0                	test   %eax,%eax
  1051c5:	78 dd                	js     1051a4 <sys_write+0x14>
  1051c7:	8b 45 f0             	mov    -0x10(%ebp),%eax
  1051ca:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  1051d1:	89 44 24 08          	mov    %eax,0x8(%esp)
  1051d5:	8d 45 ec             	lea    -0x14(%ebp),%eax
  1051d8:	89 44 24 04          	mov    %eax,0x4(%esp)
  1051dc:	e8 5f f4 ff ff       	call   104640 <argptr>
  1051e1:	85 c0                	test   %eax,%eax
  1051e3:	78 bf                	js     1051a4 <sys_write+0x14>
    return -1;
  return filewrite(f, p, n);
  1051e5:	8b 45 f0             	mov    -0x10(%ebp),%eax
  1051e8:	89 44 24 08          	mov    %eax,0x8(%esp)
  1051ec:	8b 45 ec             	mov    -0x14(%ebp),%eax
  1051ef:	89 44 24 04          	mov    %eax,0x4(%esp)
  1051f3:	8b 45 f4             	mov    -0xc(%ebp),%eax
  1051f6:	89 04 24             	mov    %eax,(%esp)
  1051f9:	e8 92 bc ff ff       	call   100e90 <filewrite>
}
  1051fe:	c9                   	leave  
  1051ff:	c3                   	ret    

00105200 <sys_fstat>:
  return 0;
}

int
sys_fstat(void)
{
  105200:	55                   	push   %ebp
  struct file *f;
  struct stat *st;
  
  if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
  105201:	31 c0                	xor    %eax,%eax
  return 0;
}

int
sys_fstat(void)
{
  105203:	89 e5                	mov    %esp,%ebp
  105205:	83 ec 28             	sub    $0x28,%esp
  struct file *f;
  struct stat *st;
  
  if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
  105208:	8d 55 f4             	lea    -0xc(%ebp),%edx
  10520b:	e8 50 fe ff ff       	call   105060 <T.67>
  105210:	85 c0                	test   %eax,%eax
  105212:	79 0c                	jns    105220 <sys_fstat+0x20>
    return -1;
  return filestat(f, st);
  105214:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  105219:	c9                   	leave  
  10521a:	c3                   	ret    
  10521b:	90                   	nop
  10521c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
sys_fstat(void)
{
  struct file *f;
  struct stat *st;
  
  if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
  105220:	8d 45 f0             	lea    -0x10(%ebp),%eax
  105223:	c7 44 24 08 14 00 00 	movl   $0x14,0x8(%esp)
  10522a:	00 
  10522b:	89 44 24 04          	mov    %eax,0x4(%esp)
  10522f:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  105236:	e8 05 f4 ff ff       	call   104640 <argptr>
  10523b:	85 c0                	test   %eax,%eax
  10523d:	78 d5                	js     105214 <sys_fstat+0x14>
    return -1;
  return filestat(f, st);
  10523f:	8b 45 f0             	mov    -0x10(%ebp),%eax
  105242:	89 44 24 04          	mov    %eax,0x4(%esp)
  105246:	8b 45 f4             	mov    -0xc(%ebp),%eax
  105249:	89 04 24             	mov    %eax,(%esp)
  10524c:	e8 9f bd ff ff       	call   100ff0 <filestat>
}
  105251:	c9                   	leave  
  105252:	c3                   	ret    
  105253:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  105259:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00105260 <sys_close>:
  return filewrite(f, p, n);
}

int
sys_close(void)
{
  105260:	55                   	push   %ebp
  105261:	89 e5                	mov    %esp,%ebp
  105263:	83 ec 28             	sub    $0x28,%esp
  int fd;
  struct file *f;
  
  if(argfd(0, &fd, &f) < 0)
  105266:	8d 55 f0             	lea    -0x10(%ebp),%edx
  105269:	8d 45 f4             	lea    -0xc(%ebp),%eax
  10526c:	e8 ef fd ff ff       	call   105060 <T.67>
  105271:	89 c2                	mov    %eax,%edx
  105273:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  105278:	85 d2                	test   %edx,%edx
  10527a:	78 1e                	js     10529a <sys_close+0x3a>
    return -1;
  proc->ofile[fd] = 0;
  10527c:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  105282:	8b 55 f4             	mov    -0xc(%ebp),%edx
  105285:	c7 44 90 28 00 00 00 	movl   $0x0,0x28(%eax,%edx,4)
  10528c:	00 
  fileclose(f);
  10528d:	8b 45 f0             	mov    -0x10(%ebp),%eax
  105290:	89 04 24             	mov    %eax,(%esp)
  105293:	e8 78 be ff ff       	call   101110 <fileclose>
  105298:	31 c0                	xor    %eax,%eax
  return 0;
}
  10529a:	c9                   	leave  
  10529b:	c3                   	ret    
  10529c:	90                   	nop
  10529d:	90                   	nop
  10529e:	90                   	nop
  10529f:	90                   	nop

001052a0 <sys_getpid>:


int
sys_getpid(void)
{
  return proc->pid;
  1052a0:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax



int
sys_getpid(void)
{
  1052a6:	55                   	push   %ebp
  1052a7:	89 e5                	mov    %esp,%ebp
  return proc->pid;
}
  1052a9:	5d                   	pop    %ebp


int
sys_getpid(void)
{
  return proc->pid;
  1052aa:	8b 40 10             	mov    0x10(%eax),%eax
}
  1052ad:	c3                   	ret    
  1052ae:	66 90                	xchg   %ax,%ax

001052b0 <sys_uptime>:

// return how many clock tick interrupts have occurred
// since boot.
int
sys_uptime(void)
{
  1052b0:	55                   	push   %ebp
  1052b1:	89 e5                	mov    %esp,%ebp
  1052b3:	53                   	push   %ebx
  1052b4:	83 ec 14             	sub    $0x14,%esp
  uint xticks;
  
  acquire(&tickslock);
  1052b7:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  1052be:	e8 fd ef ff ff       	call   1042c0 <acquire>
  xticks = ticks;
  1052c3:	8b 1d c0 fa 10 00    	mov    0x10fac0,%ebx
  release(&tickslock);
  1052c9:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  1052d0:	e8 9b ef ff ff       	call   104270 <release>
  return xticks;
}
  1052d5:	83 c4 14             	add    $0x14,%esp
  1052d8:	89 d8                	mov    %ebx,%eax
  1052da:	5b                   	pop    %ebx
  1052db:	5d                   	pop    %ebp
  1052dc:	c3                   	ret    
  1052dd:	8d 76 00             	lea    0x0(%esi),%esi

001052e0 <sys_sleep>:
  return addr;
}

int
sys_sleep(void)
{
  1052e0:	55                   	push   %ebp
  1052e1:	89 e5                	mov    %esp,%ebp
  1052e3:	53                   	push   %ebx
  1052e4:	83 ec 24             	sub    $0x24,%esp
  int n;
  uint ticks0;
  
  if(argint(0, &n) < 0)
  1052e7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  1052ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  1052ee:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  1052f5:	e8 06 f3 ff ff       	call   104600 <argint>
  1052fa:	89 c2                	mov    %eax,%edx
  1052fc:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  105301:	85 d2                	test   %edx,%edx
  105303:	78 59                	js     10535e <sys_sleep+0x7e>
    return -1;
  acquire(&tickslock);
  105305:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  10530c:	e8 af ef ff ff       	call   1042c0 <acquire>
  ticks0 = ticks;
  while(ticks - ticks0 < n){
  105311:	8b 55 f4             	mov    -0xc(%ebp),%edx
  uint ticks0;
  
  if(argint(0, &n) < 0)
    return -1;
  acquire(&tickslock);
  ticks0 = ticks;
  105314:	8b 1d c0 fa 10 00    	mov    0x10fac0,%ebx
  while(ticks - ticks0 < n){
  10531a:	85 d2                	test   %edx,%edx
  10531c:	75 22                	jne    105340 <sys_sleep+0x60>
  10531e:	eb 48                	jmp    105368 <sys_sleep+0x88>
    if(proc->killed){
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
  105320:	c7 44 24 04 80 f2 10 	movl   $0x10f280,0x4(%esp)
  105327:	00 
  105328:	c7 04 24 c0 fa 10 00 	movl   $0x10fac0,(%esp)
  10532f:	e8 4c e0 ff ff       	call   103380 <sleep>
  
  if(argint(0, &n) < 0)
    return -1;
  acquire(&tickslock);
  ticks0 = ticks;
  while(ticks - ticks0 < n){
  105334:	a1 c0 fa 10 00       	mov    0x10fac0,%eax
  105339:	29 d8                	sub    %ebx,%eax
  10533b:	3b 45 f4             	cmp    -0xc(%ebp),%eax
  10533e:	73 28                	jae    105368 <sys_sleep+0x88>
    if(proc->killed){
  105340:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  105346:	8b 40 24             	mov    0x24(%eax),%eax
  105349:	85 c0                	test   %eax,%eax
  10534b:	74 d3                	je     105320 <sys_sleep+0x40>
      release(&tickslock);
  10534d:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  105354:	e8 17 ef ff ff       	call   104270 <release>
  105359:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
    }
    sleep(&ticks, &tickslock);
  }
  release(&tickslock);
  return 0;
}
  10535e:	83 c4 24             	add    $0x24,%esp
  105361:	5b                   	pop    %ebx
  105362:	5d                   	pop    %ebp
  105363:	c3                   	ret    
  105364:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
  }
  release(&tickslock);
  105368:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  10536f:	e8 fc ee ff ff       	call   104270 <release>
  return 0;
}
  105374:	83 c4 24             	add    $0x24,%esp
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
  }
  release(&tickslock);
  105377:	31 c0                	xor    %eax,%eax
  return 0;
}
  105379:	5b                   	pop    %ebx
  10537a:	5d                   	pop    %ebp
  10537b:	c3                   	ret    
  10537c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00105380 <sys_sbrk>:
  return proc->pid;
}

int
sys_sbrk(void)
{
  105380:	55                   	push   %ebp
  105381:	89 e5                	mov    %esp,%ebp
  105383:	53                   	push   %ebx
  105384:	83 ec 24             	sub    $0x24,%esp
  int addr;
  int n;

  if(argint(0, &n) < 0)
  105387:	8d 45 f4             	lea    -0xc(%ebp),%eax
  10538a:	89 44 24 04          	mov    %eax,0x4(%esp)
  10538e:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  105395:	e8 66 f2 ff ff       	call   104600 <argint>
  10539a:	85 c0                	test   %eax,%eax
  10539c:	79 12                	jns    1053b0 <sys_sbrk+0x30>
    return -1;
  addr = proc->sz;
  if(growproc(n) < 0)
    return -1;
  return addr;
  10539e:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  1053a3:	83 c4 24             	add    $0x24,%esp
  1053a6:	5b                   	pop    %ebx
  1053a7:	5d                   	pop    %ebp
  1053a8:	c3                   	ret    
  1053a9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  int addr;
  int n;

  if(argint(0, &n) < 0)
    return -1;
  addr = proc->sz;
  1053b0:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1053b6:	8b 18                	mov    (%eax),%ebx
  if(growproc(n) < 0)
  1053b8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  1053bb:	89 04 24             	mov    %eax,(%esp)
  1053be:	e8 0d eb ff ff       	call   103ed0 <growproc>
  1053c3:	89 c2                	mov    %eax,%edx
  int addr;
  int n;

  if(argint(0, &n) < 0)
    return -1;
  addr = proc->sz;
  1053c5:	89 d8                	mov    %ebx,%eax
  if(growproc(n) < 0)
  1053c7:	85 d2                	test   %edx,%edx
  1053c9:	79 d8                	jns    1053a3 <sys_sbrk+0x23>
  1053cb:	eb d1                	jmp    10539e <sys_sbrk+0x1e>
  1053cd:	8d 76 00             	lea    0x0(%esi),%esi

001053d0 <sys_kill>:
	return nice();
}

int
sys_kill(void)
{
  1053d0:	55                   	push   %ebp
  1053d1:	89 e5                	mov    %esp,%ebp
  1053d3:	83 ec 28             	sub    $0x28,%esp
  int pid;

  if(argint(0, &pid) < 0)
  1053d6:	8d 45 f4             	lea    -0xc(%ebp),%eax
  1053d9:	89 44 24 04          	mov    %eax,0x4(%esp)
  1053dd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  1053e4:	e8 17 f2 ff ff       	call   104600 <argint>
  1053e9:	89 c2                	mov    %eax,%edx
  1053eb:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
  1053f0:	85 d2                	test   %edx,%edx
  1053f2:	78 0b                	js     1053ff <sys_kill+0x2f>
    return -1;
  return kill(pid);
  1053f4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  1053f7:	89 04 24             	mov    %eax,(%esp)
  1053fa:	e8 b1 dd ff ff       	call   1031b0 <kill>
}
  1053ff:	c9                   	leave  
  105400:	c3                   	ret    
  105401:	eb 0d                	jmp    105410 <sys_nice>
  105403:	90                   	nop
  105404:	90                   	nop
  105405:	90                   	nop
  105406:	90                   	nop
  105407:	90                   	nop
  105408:	90                   	nop
  105409:	90                   	nop
  10540a:	90                   	nop
  10540b:	90                   	nop
  10540c:	90                   	nop
  10540d:	90                   	nop
  10540e:	90                   	nop
  10540f:	90                   	nop

00105410 <sys_nice>:
	return wait2(t1, t2);
}

int
sys_nice(void)
{
  105410:	55                   	push   %ebp
  105411:	89 e5                	mov    %esp,%ebp
  105413:	83 ec 08             	sub    $0x8,%esp

	return nice();
}
  105416:	c9                   	leave  

int
sys_nice(void)
{

	return nice();
  105417:	e9 54 dd ff ff       	jmp    103170 <nice>
  10541c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00105420 <sys_wait2>:
  return wait();
}

int
sys_wait2(void)
{
  105420:	55                   	push   %ebp
  105421:	89 e5                	mov    %esp,%ebp
  105423:	83 ec 28             	sub    $0x28,%esp
 
int* t1;
int* t2;

        if((argptr(0, (void*)&t1, sizeof(t1[0])) < 0) || (argptr(1, (void*)&t2, sizeof(t2[0])) < 0))
  105426:	8d 45 f4             	lea    -0xc(%ebp),%eax
  105429:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  105430:	00 
  105431:	89 44 24 04          	mov    %eax,0x4(%esp)
  105435:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  10543c:	e8 ff f1 ff ff       	call   104640 <argptr>
  105441:	85 c0                	test   %eax,%eax
  105443:	79 0b                	jns    105450 <sys_wait2+0x30>
	//if ((argint(0, &t1) < 0) | (argint(0, &t2)) < 0) )
		return -1;
	return wait2(t1, t2);
  105445:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  10544a:	c9                   	leave  
  10544b:	c3                   	ret    
  10544c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
 
int* t1;
int* t2;

        if((argptr(0, (void*)&t1, sizeof(t1[0])) < 0) || (argptr(1, (void*)&t2, sizeof(t2[0])) < 0))
  105450:	8d 45 f0             	lea    -0x10(%ebp),%eax
  105453:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  10545a:	00 
  10545b:	89 44 24 04          	mov    %eax,0x4(%esp)
  10545f:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  105466:	e8 d5 f1 ff ff       	call   104640 <argptr>
  10546b:	85 c0                	test   %eax,%eax
  10546d:	78 d6                	js     105445 <sys_wait2+0x25>
	//if ((argint(0, &t1) < 0) | (argint(0, &t2)) < 0) )
		return -1;
	return wait2(t1, t2);
  10546f:	8b 45 f0             	mov    -0x10(%ebp),%eax
  105472:	89 44 24 04          	mov    %eax,0x4(%esp)
  105476:	8b 45 f4             	mov    -0xc(%ebp),%eax
  105479:	89 04 24             	mov    %eax,(%esp)
  10547c:	e8 df e4 ff ff       	call   103960 <wait2>
}
  105481:	c9                   	leave  
  105482:	c3                   	ret    
  105483:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  105489:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00105490 <sys_wait>:
  return 0;  // not reached
}

int
sys_wait(void)
{
  105490:	55                   	push   %ebp
  105491:	89 e5                	mov    %esp,%ebp
  105493:	83 ec 08             	sub    $0x8,%esp
  return wait();
}
  105496:	c9                   	leave  
}

int
sys_wait(void)
{
  return wait();
  105497:	e9 e4 e5 ff ff       	jmp    103a80 <wait>
  10549c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

001054a0 <sys_exit>:
  return fork();
}

int
sys_exit(void)
{
  1054a0:	55                   	push   %ebp
  1054a1:	89 e5                	mov    %esp,%ebp
  1054a3:	83 ec 08             	sub    $0x8,%esp
  exit();
  1054a6:	e8 d5 e6 ff ff       	call   103b80 <exit>
  return 0;  // not reached
}
  1054ab:	31 c0                	xor    %eax,%eax
  1054ad:	c9                   	leave  
  1054ae:	c3                   	ret    
  1054af:	90                   	nop

001054b0 <sys_fork>:
#include "mmu.h"
#include "proc.h"

int
sys_fork(void)
{
  1054b0:	55                   	push   %ebp
  1054b1:	89 e5                	mov    %esp,%ebp
  1054b3:	83 ec 08             	sub    $0x8,%esp
  return fork();
}
  1054b6:	c9                   	leave  
#include "proc.h"

int
sys_fork(void)
{
  return fork();
  1054b7:	e9 14 e9 ff ff       	jmp    103dd0 <fork>
  1054bc:	90                   	nop
  1054bd:	90                   	nop
  1054be:	90                   	nop
  1054bf:	90                   	nop

001054c0 <timerinit>:
#define TIMER_RATEGEN   0x04    // mode 2, rate generator
#define TIMER_16BIT     0x30    // r/w counter 16 bits, LSB first

void
timerinit(void)
{
  1054c0:	55                   	push   %ebp
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  1054c1:	ba 43 00 00 00       	mov    $0x43,%edx
  1054c6:	89 e5                	mov    %esp,%ebp
  1054c8:	83 ec 18             	sub    $0x18,%esp
  1054cb:	b8 34 00 00 00       	mov    $0x34,%eax
  1054d0:	ee                   	out    %al,(%dx)
  1054d1:	b8 9c ff ff ff       	mov    $0xffffff9c,%eax
  1054d6:	b2 40                	mov    $0x40,%dl
  1054d8:	ee                   	out    %al,(%dx)
  1054d9:	b8 2e 00 00 00       	mov    $0x2e,%eax
  1054de:	ee                   	out    %al,(%dx)
  // Interrupt 100 times/sec.
  outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
  outb(IO_TIMER1, TIMER_DIV(100) % 256);
  outb(IO_TIMER1, TIMER_DIV(100) / 256);
  picenable(IRQ_TIMER);
  1054df:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  1054e6:	e8 45 d8 ff ff       	call   102d30 <picenable>
}
  1054eb:	c9                   	leave  
  1054ec:	c3                   	ret    
  1054ed:	90                   	nop
  1054ee:	90                   	nop
  1054ef:	90                   	nop

001054f0 <alltraps>:

  # vectors.S sends all traps here.
.globl alltraps
alltraps:
  # Build trap frame.
  pushl %ds
  1054f0:	1e                   	push   %ds
  pushl %es
  1054f1:	06                   	push   %es
  pushl %fs
  1054f2:	0f a0                	push   %fs
  pushl %gs
  1054f4:	0f a8                	push   %gs
  pushal
  1054f6:	60                   	pusha  
  
  # Set up data and per-cpu segments.
  movw $(SEG_KDATA<<3), %ax
  1054f7:	66 b8 10 00          	mov    $0x10,%ax
  movw %ax, %ds
  1054fb:	8e d8                	mov    %eax,%ds
  movw %ax, %es
  1054fd:	8e c0                	mov    %eax,%es
  movw $(SEG_KCPU<<3), %ax
  1054ff:	66 b8 18 00          	mov    $0x18,%ax
  movw %ax, %fs
  105503:	8e e0                	mov    %eax,%fs
  movw %ax, %gs
  105505:	8e e8                	mov    %eax,%gs

  # Call trap(tf), where tf=%esp
  pushl %esp
  105507:	54                   	push   %esp
  call trap
  105508:	e8 43 00 00 00       	call   105550 <trap>
  addl $4, %esp
  10550d:	83 c4 04             	add    $0x4,%esp

00105510 <trapret>:

  # Return falls through to trapret...
.globl trapret
trapret:
  popal
  105510:	61                   	popa   
  popl %gs
  105511:	0f a9                	pop    %gs
  popl %fs
  105513:	0f a1                	pop    %fs
  popl %es
  105515:	07                   	pop    %es
  popl %ds
  105516:	1f                   	pop    %ds
  addl $0x8, %esp  # trapno and errcode
  105517:	83 c4 08             	add    $0x8,%esp
  iret
  10551a:	cf                   	iret   
  10551b:	90                   	nop
  10551c:	90                   	nop
  10551d:	90                   	nop
  10551e:	90                   	nop
  10551f:	90                   	nop

00105520 <idtinit>:
  initlock(&tickslock, "time");
}

void
idtinit(void)
{
  105520:	55                   	push   %ebp
lidt(struct gatedesc *p, int size)
{
  volatile ushort pd[3];

  pd[0] = size-1;
  pd[1] = (uint)p;
  105521:	b8 c0 f2 10 00       	mov    $0x10f2c0,%eax
  105526:	89 e5                	mov    %esp,%ebp
  105528:	83 ec 10             	sub    $0x10,%esp
static inline void
lidt(struct gatedesc *p, int size)
{
  volatile ushort pd[3];

  pd[0] = size-1;
  10552b:	66 c7 45 fa ff 07    	movw   $0x7ff,-0x6(%ebp)
  pd[1] = (uint)p;
  105531:	66 89 45 fc          	mov    %ax,-0x4(%ebp)
  pd[2] = (uint)p >> 16;
  105535:	c1 e8 10             	shr    $0x10,%eax
  105538:	66 89 45 fe          	mov    %ax,-0x2(%ebp)

  asm volatile("lidt (%0)" : : "r" (pd));
  10553c:	8d 45 fa             	lea    -0x6(%ebp),%eax
  10553f:	0f 01 18             	lidtl  (%eax)
  lidt(idt, sizeof(idt));
}
  105542:	c9                   	leave  
  105543:	c3                   	ret    
  105544:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  10554a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00105550 <trap>:

void
trap(struct trapframe *tf)
{
  105550:	55                   	push   %ebp
  105551:	89 e5                	mov    %esp,%ebp
  105553:	56                   	push   %esi
  105554:	53                   	push   %ebx
  105555:	83 ec 20             	sub    $0x20,%esp
  105558:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if(tf->trapno == T_SYSCALL){
  10555b:	8b 43 30             	mov    0x30(%ebx),%eax
  10555e:	83 f8 40             	cmp    $0x40,%eax
  105561:	0f 84 d1 00 00 00    	je     105638 <trap+0xe8>
    if(proc->killed)
      exit();
    return;
  }

  switch(tf->trapno){
  105567:	8d 50 e0             	lea    -0x20(%eax),%edx
  10556a:	83 fa 1f             	cmp    $0x1f,%edx
  10556d:	0f 86 bd 00 00 00    	jbe    105630 <trap+0xe0>
            cpu->id, tf->cs, tf->eip);
    lapiceoi();
    break;
   
  default:
    if(proc == 0 || (tf->cs&3) == 0){
  105573:	65 8b 15 04 00 00 00 	mov    %gs:0x4,%edx
  10557a:	85 d2                	test   %edx,%edx
  10557c:	0f 84 12 02 00 00    	je     105794 <trap+0x244>
  105582:	f6 43 3c 03          	testb  $0x3,0x3c(%ebx)
  105586:	0f 84 08 02 00 00    	je     105794 <trap+0x244>

static inline uint
rcr2(void)
{
  uint val;
  asm volatile("movl %%cr2,%0" : "=r" (val));
  10558c:	0f 20 d6             	mov    %cr2,%esi
      cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n",
              tf->trapno, cpu->id, tf->eip, rcr2());
      panic("trap");
    }
    // In user space, assume process misbehaved.
    cprintf("pid %d %s: trap %d err %d on cpu %d "
  10558f:	8b 4a 10             	mov    0x10(%edx),%ecx
  105592:	83 c2 6c             	add    $0x6c,%edx
  105595:	89 74 24 1c          	mov    %esi,0x1c(%esp)
  105599:	8b 73 38             	mov    0x38(%ebx),%esi
  10559c:	89 74 24 18          	mov    %esi,0x18(%esp)
  1055a0:	65 8b 35 00 00 00 00 	mov    %gs:0x0,%esi
  1055a7:	0f b6 36             	movzbl (%esi),%esi
  1055aa:	89 74 24 14          	mov    %esi,0x14(%esp)
  1055ae:	8b 73 34             	mov    0x34(%ebx),%esi
  1055b1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  1055b5:	89 54 24 08          	mov    %edx,0x8(%esp)
  1055b9:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  1055bd:	89 74 24 10          	mov    %esi,0x10(%esp)
  1055c1:	c7 04 24 bc 73 10 00 	movl   $0x1073bc,(%esp)
  1055c8:	e8 f3 ae ff ff       	call   1004c0 <cprintf>
            "eip 0x%x addr 0x%x--kill proc\n",
            proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, 
            rcr2());
    proc->killed = 1;
  1055cd:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  1055d3:	c7 40 24 01 00 00 00 	movl   $0x1,0x24(%eax)
  1055da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  }

   // Force process exit if it has been killed and is in user space.
  // (If it is still executing in the kernel, let it keep running 
  // until it gets to the regular system call return.)
  if(proc && proc->killed && (tf->cs&3) == DPL_USER){
  1055e0:	65 8b 35 04 00 00 00 	mov    %gs:0x4,%esi
  1055e7:	85 f6                	test   %esi,%esi
  1055e9:	74 6f                	je     10565a <trap+0x10a>
  1055eb:	8b 56 24             	mov    0x24(%esi),%edx
  1055ee:	85 d2                	test   %edx,%edx
  1055f0:	74 10                	je     105602 <trap+0xb2>
  1055f2:	0f b7 43 3c          	movzwl 0x3c(%ebx),%eax
  1055f6:	83 e0 03             	and    $0x3,%eax
  1055f9:	83 f8 03             	cmp    $0x3,%eax
  1055fc:	0f 84 6e 01 00 00    	je     105770 <trap+0x220>
	exit();
  }

  // Force process to give up CPU on clock tick.
  // If interrupts were on while locks held, would need to check nlock.
  if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER){
  105602:	83 7e 0c 04          	cmpl   $0x4,0xc(%esi)
  105606:	0f 84 34 01 00 00    	je     105740 <trap+0x1f0>
  }
goto schedflag_label;
schedflag_label:
  
  // Check if the process has been killed since we yielded
  if(proc && proc->killed && (tf->cs&3) == DPL_USER)
  10560c:	8b 46 24             	mov    0x24(%esi),%eax
  10560f:	85 c0                	test   %eax,%eax
  105611:	74 47                	je     10565a <trap+0x10a>
  105613:	0f b7 43 3c          	movzwl 0x3c(%ebx),%eax
  105617:	83 e0 03             	and    $0x3,%eax
  10561a:	83 f8 03             	cmp    $0x3,%eax
  10561d:	75 3b                	jne    10565a <trap+0x10a>
    exit();
}
  10561f:	83 c4 20             	add    $0x20,%esp
  105622:	5b                   	pop    %ebx
  105623:	5e                   	pop    %esi
  105624:	5d                   	pop    %ebp
goto schedflag_label;
schedflag_label:
  
  // Check if the process has been killed since we yielded
  if(proc && proc->killed && (tf->cs&3) == DPL_USER)
    exit();
  105625:	e9 56 e5 ff ff       	jmp    103b80 <exit>
  10562a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    if(proc->killed)
      exit();
    return;
  }

  switch(tf->trapno){
  105630:	ff 24 95 0c 74 10 00 	jmp    *0x10740c(,%edx,4)
  105637:	90                   	nop

void
trap(struct trapframe *tf)
{
  if(tf->trapno == T_SYSCALL){
    if(proc->killed)
  105638:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  10563e:	8b 70 24             	mov    0x24(%eax),%esi
  105641:	85 f6                	test   %esi,%esi
  105643:	75 23                	jne    105668 <trap+0x118>
      exit();
    proc->tf = tf;
  105645:	89 58 18             	mov    %ebx,0x18(%eax)
    syscall();
  105648:	e8 b3 f0 ff ff       	call   104700 <syscall>
    if(proc->killed)
  10564d:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  105653:	8b 48 24             	mov    0x24(%eax),%ecx
  105656:	85 c9                	test   %ecx,%ecx
  105658:	75 c5                	jne    10561f <trap+0xcf>
schedflag_label:
  
  // Check if the process has been killed since we yielded
  if(proc && proc->killed && (tf->cs&3) == DPL_USER)
    exit();
}
  10565a:	83 c4 20             	add    $0x20,%esp
  10565d:	5b                   	pop    %ebx
  10565e:	5e                   	pop    %esi
  10565f:	5d                   	pop    %ebp
  105660:	c3                   	ret    
  105661:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
void
trap(struct trapframe *tf)
{
  if(tf->trapno == T_SYSCALL){
    if(proc->killed)
      exit();
  105668:	e8 13 e5 ff ff       	call   103b80 <exit>
  10566d:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  105673:	eb d0                	jmp    105645 <trap+0xf5>
  105675:	8d 76 00             	lea    0x0(%esi),%esi
    uartintr();
    lapiceoi();
    break;
  case T_IRQ0 + 7:
  case T_IRQ0 + IRQ_SPURIOUS:
    cprintf("cpu%d: spurious interrupt at %x:%x\n",
  105678:	8b 43 38             	mov    0x38(%ebx),%eax
  10567b:	89 44 24 0c          	mov    %eax,0xc(%esp)
  10567f:	0f b7 43 3c          	movzwl 0x3c(%ebx),%eax
  105683:	89 44 24 08          	mov    %eax,0x8(%esp)
  105687:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  10568d:	0f b6 00             	movzbl (%eax),%eax
  105690:	c7 04 24 64 73 10 00 	movl   $0x107364,(%esp)
  105697:	89 44 24 04          	mov    %eax,0x4(%esp)
  10569b:	e8 20 ae ff ff       	call   1004c0 <cprintf>
            cpu->id, tf->cs, tf->eip);
    lapiceoi();
  1056a0:	e8 5b cf ff ff       	call   102600 <lapiceoi>
    break;
  1056a5:	e9 36 ff ff ff       	jmp    1055e0 <trap+0x90>
  1056aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  case T_IRQ0 + IRQ_KBD:
    kbdintr();
    lapiceoi();
    break;
  case T_IRQ0 + IRQ_COM1:
    uartintr();
  1056b0:	e8 db 01 00 00       	call   105890 <uartintr>
  1056b5:	8d 76 00             	lea    0x0(%esi),%esi
    lapiceoi();
  1056b8:	e8 43 cf ff ff       	call   102600 <lapiceoi>
  1056bd:	8d 76 00             	lea    0x0(%esi),%esi
    break;
  1056c0:	e9 1b ff ff ff       	jmp    1055e0 <trap+0x90>
  1056c5:	8d 76 00             	lea    0x0(%esi),%esi
  1056c8:	90                   	nop
  1056c9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
      release(&tickslock);
    }
    lapiceoi();
    break;
  case T_IRQ0 + IRQ_IDE:
    ideintr();
  1056d0:	e8 cb ca ff ff       	call   1021a0 <ideintr>
  1056d5:	8d 76 00             	lea    0x0(%esi),%esi
    lapiceoi();
  1056d8:	e8 23 cf ff ff       	call   102600 <lapiceoi>
  1056dd:	8d 76 00             	lea    0x0(%esi),%esi
    break;
  1056e0:	e9 fb fe ff ff       	jmp    1055e0 <trap+0x90>
  1056e5:	8d 76 00             	lea    0x0(%esi),%esi
  1056e8:	90                   	nop
  1056e9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  case T_IRQ0 + IRQ_KBD:
    kbdintr();
  1056f0:	e8 eb ce ff ff       	call   1025e0 <kbdintr>
  1056f5:	8d 76 00             	lea    0x0(%esi),%esi
    lapiceoi();
  1056f8:	e8 03 cf ff ff       	call   102600 <lapiceoi>
  1056fd:	8d 76 00             	lea    0x0(%esi),%esi
    break;
  105700:	e9 db fe ff ff       	jmp    1055e0 <trap+0x90>
  105705:	8d 76 00             	lea    0x0(%esi),%esi
    return;
  }

  switch(tf->trapno){
  case T_IRQ0 + IRQ_TIMER:
    if(cpu->id == 0){
  105708:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  10570e:	80 38 00             	cmpb   $0x0,(%eax)
  105711:	75 c2                	jne    1056d5 <trap+0x185>
      acquire(&tickslock);
  105713:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  10571a:	e8 a1 eb ff ff       	call   1042c0 <acquire>
      ticks++;
  10571f:	83 05 c0 fa 10 00 01 	addl   $0x1,0x10fac0
      wakeup(&ticks);
  105726:	c7 04 24 c0 fa 10 00 	movl   $0x10fac0,(%esp)
  10572d:	e8 1e db ff ff       	call   103250 <wakeup>
      release(&tickslock);
  105732:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
  105739:	e8 32 eb ff ff       	call   104270 <release>
  10573e:	eb 95                	jmp    1056d5 <trap+0x185>
	exit();
  }

  // Force process to give up CPU on clock tick.
  // If interrupts were on while locks held, would need to check nlock.
  if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER){
  105740:	83 7b 30 20          	cmpl   $0x20,0x30(%ebx)
  105744:	0f 85 c2 fe ff ff    	jne    10560c <trap+0xbc>
  10574a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
		goto schedflag_label;
	}
}
#endif
	
	yield();
  105750:	e8 fb dc ff ff       	call   103450 <yield>
  }
goto schedflag_label;
schedflag_label:
  
  // Check if the process has been killed since we yielded
  if(proc && proc->killed && (tf->cs&3) == DPL_USER)
  105755:	65 8b 35 04 00 00 00 	mov    %gs:0x4,%esi
  10575c:	85 f6                	test   %esi,%esi
  10575e:	0f 85 a8 fe ff ff    	jne    10560c <trap+0xbc>
  105764:	e9 f1 fe ff ff       	jmp    10565a <trap+0x10a>
  105769:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

   // Force process exit if it has been killed and is in user space.
  // (If it is still executing in the kernel, let it keep running 
  // until it gets to the regular system call return.)
  if(proc && proc->killed && (tf->cs&3) == DPL_USER){
	proc->etime = sys_uptime();
  105770:	e8 3b fb ff ff       	call   1052b0 <sys_uptime>
  105775:	89 86 84 00 00 00    	mov    %eax,0x84(%esi)
	exit();
  10577b:	e8 00 e4 ff ff       	call   103b80 <exit>
  }

  // Force process to give up CPU on clock tick.
  // If interrupts were on while locks held, would need to check nlock.
  if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER){
  105780:	65 8b 35 04 00 00 00 	mov    %gs:0x4,%esi
  105787:	85 f6                	test   %esi,%esi
  105789:	0f 85 73 fe ff ff    	jne    105602 <trap+0xb2>
  10578f:	e9 c6 fe ff ff       	jmp    10565a <trap+0x10a>
  105794:	0f 20 d2             	mov    %cr2,%edx
    break;
   
  default:
    if(proc == 0 || (tf->cs&3) == 0){
      // In kernel, it must be our mistake.
      cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n",
  105797:	89 54 24 10          	mov    %edx,0x10(%esp)
  10579b:	8b 53 38             	mov    0x38(%ebx),%edx
  10579e:	89 54 24 0c          	mov    %edx,0xc(%esp)
  1057a2:	65 8b 15 00 00 00 00 	mov    %gs:0x0,%edx
  1057a9:	0f b6 12             	movzbl (%edx),%edx
  1057ac:	89 44 24 04          	mov    %eax,0x4(%esp)
  1057b0:	c7 04 24 88 73 10 00 	movl   $0x107388,(%esp)
  1057b7:	89 54 24 08          	mov    %edx,0x8(%esp)
  1057bb:	e8 00 ad ff ff       	call   1004c0 <cprintf>
              tf->trapno, cpu->id, tf->eip, rcr2());
      panic("trap");
  1057c0:	c7 04 24 ff 73 10 00 	movl   $0x1073ff,(%esp)
  1057c7:	e8 94 b2 ff ff       	call   100a60 <panic>
  1057cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

001057d0 <tvinit>:
uint ticks;
int tmpQuanta=0;

void
tvinit(void)
{
  1057d0:	55                   	push   %ebp
  1057d1:	31 c0                	xor    %eax,%eax
  1057d3:	89 e5                	mov    %esp,%ebp
  1057d5:	ba c0 f2 10 00       	mov    $0x10f2c0,%edx
  1057da:	83 ec 18             	sub    $0x18,%esp
  1057dd:	8d 76 00             	lea    0x0(%esi),%esi
  int i;

  for(i = 0; i < 256; i++)
    SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0);
  1057e0:	8b 0c 85 88 88 10 00 	mov    0x108888(,%eax,4),%ecx
  1057e7:	66 89 0c c5 c0 f2 10 	mov    %cx,0x10f2c0(,%eax,8)
  1057ee:	00 
  1057ef:	c1 e9 10             	shr    $0x10,%ecx
  1057f2:	66 c7 44 c2 02 08 00 	movw   $0x8,0x2(%edx,%eax,8)
  1057f9:	c6 44 c2 04 00       	movb   $0x0,0x4(%edx,%eax,8)
  1057fe:	c6 44 c2 05 8e       	movb   $0x8e,0x5(%edx,%eax,8)
  105803:	66 89 4c c2 06       	mov    %cx,0x6(%edx,%eax,8)
void
tvinit(void)
{
  int i;

  for(i = 0; i < 256; i++)
  105808:	83 c0 01             	add    $0x1,%eax
  10580b:	3d 00 01 00 00       	cmp    $0x100,%eax
  105810:	75 ce                	jne    1057e0 <tvinit+0x10>
    SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0);
  SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER);
  105812:	a1 88 89 10 00       	mov    0x108988,%eax
  
  initlock(&tickslock, "time");
  105817:	c7 44 24 04 04 74 10 	movl   $0x107404,0x4(%esp)
  10581e:	00 
  10581f:	c7 04 24 80 f2 10 00 	movl   $0x10f280,(%esp)
{
  int i;

  for(i = 0; i < 256; i++)
    SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0);
  SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER);
  105826:	66 c7 05 c2 f4 10 00 	movw   $0x8,0x10f4c2
  10582d:	08 00 
  10582f:	66 a3 c0 f4 10 00    	mov    %ax,0x10f4c0
  105835:	c1 e8 10             	shr    $0x10,%eax
  105838:	c6 05 c4 f4 10 00 00 	movb   $0x0,0x10f4c4
  10583f:	c6 05 c5 f4 10 00 ef 	movb   $0xef,0x10f4c5
  105846:	66 a3 c6 f4 10 00    	mov    %ax,0x10f4c6
  
  initlock(&tickslock, "time");
  10584c:	e8 df e8 ff ff       	call   104130 <initlock>
}
  105851:	c9                   	leave  
  105852:	c3                   	ret    
  105853:	90                   	nop
  105854:	90                   	nop
  105855:	90                   	nop
  105856:	90                   	nop
  105857:	90                   	nop
  105858:	90                   	nop
  105859:	90                   	nop
  10585a:	90                   	nop
  10585b:	90                   	nop
  10585c:	90                   	nop
  10585d:	90                   	nop
  10585e:	90                   	nop
  10585f:	90                   	nop

00105860 <uartgetc>:
}

static int
uartgetc(void)
{
  if(!uart)
  105860:	a1 d0 95 10 00       	mov    0x1095d0,%eax
  outb(COM1+0, c);
}

static int
uartgetc(void)
{
  105865:	55                   	push   %ebp
  105866:	89 e5                	mov    %esp,%ebp
  if(!uart)
  105868:	85 c0                	test   %eax,%eax
  10586a:	75 0c                	jne    105878 <uartgetc+0x18>
    return -1;
  if(!(inb(COM1+5) & 0x01))
    return -1;
  return inb(COM1+0);
  10586c:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
}
  105871:	5d                   	pop    %ebp
  105872:	c3                   	ret    
  105873:	90                   	nop
  105874:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  105878:	ba fd 03 00 00       	mov    $0x3fd,%edx
  10587d:	ec                   	in     (%dx),%al
static int
uartgetc(void)
{
  if(!uart)
    return -1;
  if(!(inb(COM1+5) & 0x01))
  10587e:	a8 01                	test   $0x1,%al
  105880:	74 ea                	je     10586c <uartgetc+0xc>
  105882:	b2 f8                	mov    $0xf8,%dl
  105884:	ec                   	in     (%dx),%al
    return -1;
  return inb(COM1+0);
  105885:	0f b6 c0             	movzbl %al,%eax
}
  105888:	5d                   	pop    %ebp
  105889:	c3                   	ret    
  10588a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00105890 <uartintr>:

void
uartintr(void)
{
  105890:	55                   	push   %ebp
  105891:	89 e5                	mov    %esp,%ebp
  105893:	83 ec 18             	sub    $0x18,%esp
  consoleintr(uartgetc);
  105896:	c7 04 24 60 58 10 00 	movl   $0x105860,(%esp)
  10589d:	e8 7e ae ff ff       	call   100720 <consoleintr>
}
  1058a2:	c9                   	leave  
  1058a3:	c3                   	ret    
  1058a4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  1058aa:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

001058b0 <uartputc>:
    uartputc(*p);
}

void
uartputc(int c)
{
  1058b0:	55                   	push   %ebp
  1058b1:	89 e5                	mov    %esp,%ebp
  1058b3:	56                   	push   %esi
  1058b4:	be fd 03 00 00       	mov    $0x3fd,%esi
  1058b9:	53                   	push   %ebx
  int i;

  if(!uart)
  1058ba:	31 db                	xor    %ebx,%ebx
    uartputc(*p);
}

void
uartputc(int c)
{
  1058bc:	83 ec 10             	sub    $0x10,%esp
  int i;

  if(!uart)
  1058bf:	8b 15 d0 95 10 00    	mov    0x1095d0,%edx
  1058c5:	85 d2                	test   %edx,%edx
  1058c7:	75 1e                	jne    1058e7 <uartputc+0x37>
  1058c9:	eb 2c                	jmp    1058f7 <uartputc+0x47>
  1058cb:	90                   	nop
  1058cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    return;
  for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
  1058d0:	83 c3 01             	add    $0x1,%ebx
    microdelay(10);
  1058d3:	c7 04 24 0a 00 00 00 	movl   $0xa,(%esp)
  1058da:	e8 41 cd ff ff       	call   102620 <microdelay>
{
  int i;

  if(!uart)
    return;
  for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
  1058df:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  1058e5:	74 07                	je     1058ee <uartputc+0x3e>
  1058e7:	89 f2                	mov    %esi,%edx
  1058e9:	ec                   	in     (%dx),%al
  1058ea:	a8 20                	test   $0x20,%al
  1058ec:	74 e2                	je     1058d0 <uartputc+0x20>
}

static inline void
outb(ushort port, uchar data)
{
  asm volatile("out %0,%1" : : "a" (data), "d" (port));
  1058ee:	ba f8 03 00 00       	mov    $0x3f8,%edx
  1058f3:	8b 45 08             	mov    0x8(%ebp),%eax
  1058f6:	ee                   	out    %al,(%dx)
    microdelay(10);
  outb(COM1+0, c);
}
  1058f7:	83 c4 10             	add    $0x10,%esp
  1058fa:	5b                   	pop    %ebx
  1058fb:	5e                   	pop    %esi
  1058fc:	5d                   	pop    %ebp
  1058fd:	c3                   	ret    
  1058fe:	66 90                	xchg   %ax,%ax

00105900 <uartinit>:

static int uart;    // is there a uart?

void
uartinit(void)
{
  105900:	55                   	push   %ebp
  105901:	31 c9                	xor    %ecx,%ecx
  105903:	89 e5                	mov    %esp,%ebp
  105905:	89 c8                	mov    %ecx,%eax
  105907:	57                   	push   %edi
  105908:	bf fa 03 00 00       	mov    $0x3fa,%edi
  10590d:	56                   	push   %esi
  10590e:	89 fa                	mov    %edi,%edx
  105910:	53                   	push   %ebx
  105911:	83 ec 1c             	sub    $0x1c,%esp
  105914:	ee                   	out    %al,(%dx)
  105915:	bb fb 03 00 00       	mov    $0x3fb,%ebx
  10591a:	b8 80 ff ff ff       	mov    $0xffffff80,%eax
  10591f:	89 da                	mov    %ebx,%edx
  105921:	ee                   	out    %al,(%dx)
  105922:	b8 0c 00 00 00       	mov    $0xc,%eax
  105927:	b2 f8                	mov    $0xf8,%dl
  105929:	ee                   	out    %al,(%dx)
  10592a:	be f9 03 00 00       	mov    $0x3f9,%esi
  10592f:	89 c8                	mov    %ecx,%eax
  105931:	89 f2                	mov    %esi,%edx
  105933:	ee                   	out    %al,(%dx)
  105934:	b8 03 00 00 00       	mov    $0x3,%eax
  105939:	89 da                	mov    %ebx,%edx
  10593b:	ee                   	out    %al,(%dx)
  10593c:	b2 fc                	mov    $0xfc,%dl
  10593e:	89 c8                	mov    %ecx,%eax
  105940:	ee                   	out    %al,(%dx)
  105941:	b8 01 00 00 00       	mov    $0x1,%eax
  105946:	89 f2                	mov    %esi,%edx
  105948:	ee                   	out    %al,(%dx)
static inline uchar
inb(ushort port)
{
  uchar data;

  asm volatile("in %1,%0" : "=a" (data) : "d" (port));
  105949:	b2 fd                	mov    $0xfd,%dl
  10594b:	ec                   	in     (%dx),%al
  outb(COM1+3, 0x03);    // Lock divisor, 8 data bits.
  outb(COM1+4, 0);
  outb(COM1+1, 0x01);    // Enable receive interrupts.

  // If status is 0xFF, no serial port.
  if(inb(COM1+5) == 0xFF)
  10594c:	3c ff                	cmp    $0xff,%al
  10594e:	74 55                	je     1059a5 <uartinit+0xa5>
    return;
  uart = 1;
  105950:	c7 05 d0 95 10 00 01 	movl   $0x1,0x1095d0
  105957:	00 00 00 
  10595a:	89 fa                	mov    %edi,%edx
  10595c:	ec                   	in     (%dx),%al
  10595d:	b2 f8                	mov    $0xf8,%dl
  10595f:	ec                   	in     (%dx),%al
  // Acknowledge pre-existing interrupt conditions;
  // enable interrupts.
  inb(COM1+2);
  inb(COM1+0);
  picenable(IRQ_COM1);
  ioapicenable(IRQ_COM1, 0);
  105960:	bb 8c 74 10 00       	mov    $0x10748c,%ebx

  // Acknowledge pre-existing interrupt conditions;
  // enable interrupts.
  inb(COM1+2);
  inb(COM1+0);
  picenable(IRQ_COM1);
  105965:	c7 04 24 04 00 00 00 	movl   $0x4,(%esp)
  10596c:	e8 bf d3 ff ff       	call   102d30 <picenable>
  ioapicenable(IRQ_COM1, 0);
  105971:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  105978:	00 
  105979:	c7 04 24 04 00 00 00 	movl   $0x4,(%esp)
  105980:	e8 6b c9 ff ff       	call   1022f0 <ioapicenable>
  105985:	b8 78 00 00 00       	mov    $0x78,%eax
  10598a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  
  // Announce that we're here.
  for(p="xv6...\n"; *p; p++)
    uartputc(*p);
  105990:	0f be c0             	movsbl %al,%eax
  inb(COM1+0);
  picenable(IRQ_COM1);
  ioapicenable(IRQ_COM1, 0);
  
  // Announce that we're here.
  for(p="xv6...\n"; *p; p++)
  105993:	83 c3 01             	add    $0x1,%ebx
    uartputc(*p);
  105996:	89 04 24             	mov    %eax,(%esp)
  105999:	e8 12 ff ff ff       	call   1058b0 <uartputc>
  inb(COM1+0);
  picenable(IRQ_COM1);
  ioapicenable(IRQ_COM1, 0);
  
  // Announce that we're here.
  for(p="xv6...\n"; *p; p++)
  10599e:	0f b6 03             	movzbl (%ebx),%eax
  1059a1:	84 c0                	test   %al,%al
  1059a3:	75 eb                	jne    105990 <uartinit+0x90>
    uartputc(*p);
}
  1059a5:	83 c4 1c             	add    $0x1c,%esp
  1059a8:	5b                   	pop    %ebx
  1059a9:	5e                   	pop    %esi
  1059aa:	5f                   	pop    %edi
  1059ab:	5d                   	pop    %ebp
  1059ac:	c3                   	ret    
  1059ad:	90                   	nop
  1059ae:	90                   	nop
  1059af:	90                   	nop

001059b0 <vector0>:
# generated by vectors.pl - do not edit
# handlers
.globl alltraps
.globl vector0
vector0:
  pushl $0
  1059b0:	6a 00                	push   $0x0
  pushl $0
  1059b2:	6a 00                	push   $0x0
  jmp alltraps
  1059b4:	e9 37 fb ff ff       	jmp    1054f0 <alltraps>

001059b9 <vector1>:
.globl vector1
vector1:
  pushl $0
  1059b9:	6a 00                	push   $0x0
  pushl $1
  1059bb:	6a 01                	push   $0x1
  jmp alltraps
  1059bd:	e9 2e fb ff ff       	jmp    1054f0 <alltraps>

001059c2 <vector2>:
.globl vector2
vector2:
  pushl $0
  1059c2:	6a 00                	push   $0x0
  pushl $2
  1059c4:	6a 02                	push   $0x2
  jmp alltraps
  1059c6:	e9 25 fb ff ff       	jmp    1054f0 <alltraps>

001059cb <vector3>:
.globl vector3
vector3:
  pushl $0
  1059cb:	6a 00                	push   $0x0
  pushl $3
  1059cd:	6a 03                	push   $0x3
  jmp alltraps
  1059cf:	e9 1c fb ff ff       	jmp    1054f0 <alltraps>

001059d4 <vector4>:
.globl vector4
vector4:
  pushl $0
  1059d4:	6a 00                	push   $0x0
  pushl $4
  1059d6:	6a 04                	push   $0x4
  jmp alltraps
  1059d8:	e9 13 fb ff ff       	jmp    1054f0 <alltraps>

001059dd <vector5>:
.globl vector5
vector5:
  pushl $0
  1059dd:	6a 00                	push   $0x0
  pushl $5
  1059df:	6a 05                	push   $0x5
  jmp alltraps
  1059e1:	e9 0a fb ff ff       	jmp    1054f0 <alltraps>

001059e6 <vector6>:
.globl vector6
vector6:
  pushl $0
  1059e6:	6a 00                	push   $0x0
  pushl $6
  1059e8:	6a 06                	push   $0x6
  jmp alltraps
  1059ea:	e9 01 fb ff ff       	jmp    1054f0 <alltraps>

001059ef <vector7>:
.globl vector7
vector7:
  pushl $0
  1059ef:	6a 00                	push   $0x0
  pushl $7
  1059f1:	6a 07                	push   $0x7
  jmp alltraps
  1059f3:	e9 f8 fa ff ff       	jmp    1054f0 <alltraps>

001059f8 <vector8>:
.globl vector8
vector8:
  pushl $8
  1059f8:	6a 08                	push   $0x8
  jmp alltraps
  1059fa:	e9 f1 fa ff ff       	jmp    1054f0 <alltraps>

001059ff <vector9>:
.globl vector9
vector9:
  pushl $0
  1059ff:	6a 00                	push   $0x0
  pushl $9
  105a01:	6a 09                	push   $0x9
  jmp alltraps
  105a03:	e9 e8 fa ff ff       	jmp    1054f0 <alltraps>

00105a08 <vector10>:
.globl vector10
vector10:
  pushl $10
  105a08:	6a 0a                	push   $0xa
  jmp alltraps
  105a0a:	e9 e1 fa ff ff       	jmp    1054f0 <alltraps>

00105a0f <vector11>:
.globl vector11
vector11:
  pushl $11
  105a0f:	6a 0b                	push   $0xb
  jmp alltraps
  105a11:	e9 da fa ff ff       	jmp    1054f0 <alltraps>

00105a16 <vector12>:
.globl vector12
vector12:
  pushl $12
  105a16:	6a 0c                	push   $0xc
  jmp alltraps
  105a18:	e9 d3 fa ff ff       	jmp    1054f0 <alltraps>

00105a1d <vector13>:
.globl vector13
vector13:
  pushl $13
  105a1d:	6a 0d                	push   $0xd
  jmp alltraps
  105a1f:	e9 cc fa ff ff       	jmp    1054f0 <alltraps>

00105a24 <vector14>:
.globl vector14
vector14:
  pushl $14
  105a24:	6a 0e                	push   $0xe
  jmp alltraps
  105a26:	e9 c5 fa ff ff       	jmp    1054f0 <alltraps>

00105a2b <vector15>:
.globl vector15
vector15:
  pushl $0
  105a2b:	6a 00                	push   $0x0
  pushl $15
  105a2d:	6a 0f                	push   $0xf
  jmp alltraps
  105a2f:	e9 bc fa ff ff       	jmp    1054f0 <alltraps>

00105a34 <vector16>:
.globl vector16
vector16:
  pushl $0
  105a34:	6a 00                	push   $0x0
  pushl $16
  105a36:	6a 10                	push   $0x10
  jmp alltraps
  105a38:	e9 b3 fa ff ff       	jmp    1054f0 <alltraps>

00105a3d <vector17>:
.globl vector17
vector17:
  pushl $17
  105a3d:	6a 11                	push   $0x11
  jmp alltraps
  105a3f:	e9 ac fa ff ff       	jmp    1054f0 <alltraps>

00105a44 <vector18>:
.globl vector18
vector18:
  pushl $0
  105a44:	6a 00                	push   $0x0
  pushl $18
  105a46:	6a 12                	push   $0x12
  jmp alltraps
  105a48:	e9 a3 fa ff ff       	jmp    1054f0 <alltraps>

00105a4d <vector19>:
.globl vector19
vector19:
  pushl $0
  105a4d:	6a 00                	push   $0x0
  pushl $19
  105a4f:	6a 13                	push   $0x13
  jmp alltraps
  105a51:	e9 9a fa ff ff       	jmp    1054f0 <alltraps>

00105a56 <vector20>:
.globl vector20
vector20:
  pushl $0
  105a56:	6a 00                	push   $0x0
  pushl $20
  105a58:	6a 14                	push   $0x14
  jmp alltraps
  105a5a:	e9 91 fa ff ff       	jmp    1054f0 <alltraps>

00105a5f <vector21>:
.globl vector21
vector21:
  pushl $0
  105a5f:	6a 00                	push   $0x0
  pushl $21
  105a61:	6a 15                	push   $0x15
  jmp alltraps
  105a63:	e9 88 fa ff ff       	jmp    1054f0 <alltraps>

00105a68 <vector22>:
.globl vector22
vector22:
  pushl $0
  105a68:	6a 00                	push   $0x0
  pushl $22
  105a6a:	6a 16                	push   $0x16
  jmp alltraps
  105a6c:	e9 7f fa ff ff       	jmp    1054f0 <alltraps>

00105a71 <vector23>:
.globl vector23
vector23:
  pushl $0
  105a71:	6a 00                	push   $0x0
  pushl $23
  105a73:	6a 17                	push   $0x17
  jmp alltraps
  105a75:	e9 76 fa ff ff       	jmp    1054f0 <alltraps>

00105a7a <vector24>:
.globl vector24
vector24:
  pushl $0
  105a7a:	6a 00                	push   $0x0
  pushl $24
  105a7c:	6a 18                	push   $0x18
  jmp alltraps
  105a7e:	e9 6d fa ff ff       	jmp    1054f0 <alltraps>

00105a83 <vector25>:
.globl vector25
vector25:
  pushl $0
  105a83:	6a 00                	push   $0x0
  pushl $25
  105a85:	6a 19                	push   $0x19
  jmp alltraps
  105a87:	e9 64 fa ff ff       	jmp    1054f0 <alltraps>

00105a8c <vector26>:
.globl vector26
vector26:
  pushl $0
  105a8c:	6a 00                	push   $0x0
  pushl $26
  105a8e:	6a 1a                	push   $0x1a
  jmp alltraps
  105a90:	e9 5b fa ff ff       	jmp    1054f0 <alltraps>

00105a95 <vector27>:
.globl vector27
vector27:
  pushl $0
  105a95:	6a 00                	push   $0x0
  pushl $27
  105a97:	6a 1b                	push   $0x1b
  jmp alltraps
  105a99:	e9 52 fa ff ff       	jmp    1054f0 <alltraps>

00105a9e <vector28>:
.globl vector28
vector28:
  pushl $0
  105a9e:	6a 00                	push   $0x0
  pushl $28
  105aa0:	6a 1c                	push   $0x1c
  jmp alltraps
  105aa2:	e9 49 fa ff ff       	jmp    1054f0 <alltraps>

00105aa7 <vector29>:
.globl vector29
vector29:
  pushl $0
  105aa7:	6a 00                	push   $0x0
  pushl $29
  105aa9:	6a 1d                	push   $0x1d
  jmp alltraps
  105aab:	e9 40 fa ff ff       	jmp    1054f0 <alltraps>

00105ab0 <vector30>:
.globl vector30
vector30:
  pushl $0
  105ab0:	6a 00                	push   $0x0
  pushl $30
  105ab2:	6a 1e                	push   $0x1e
  jmp alltraps
  105ab4:	e9 37 fa ff ff       	jmp    1054f0 <alltraps>

00105ab9 <vector31>:
.globl vector31
vector31:
  pushl $0
  105ab9:	6a 00                	push   $0x0
  pushl $31
  105abb:	6a 1f                	push   $0x1f
  jmp alltraps
  105abd:	e9 2e fa ff ff       	jmp    1054f0 <alltraps>

00105ac2 <vector32>:
.globl vector32
vector32:
  pushl $0
  105ac2:	6a 00                	push   $0x0
  pushl $32
  105ac4:	6a 20                	push   $0x20
  jmp alltraps
  105ac6:	e9 25 fa ff ff       	jmp    1054f0 <alltraps>

00105acb <vector33>:
.globl vector33
vector33:
  pushl $0
  105acb:	6a 00                	push   $0x0
  pushl $33
  105acd:	6a 21                	push   $0x21
  jmp alltraps
  105acf:	e9 1c fa ff ff       	jmp    1054f0 <alltraps>

00105ad4 <vector34>:
.globl vector34
vector34:
  pushl $0
  105ad4:	6a 00                	push   $0x0
  pushl $34
  105ad6:	6a 22                	push   $0x22
  jmp alltraps
  105ad8:	e9 13 fa ff ff       	jmp    1054f0 <alltraps>

00105add <vector35>:
.globl vector35
vector35:
  pushl $0
  105add:	6a 00                	push   $0x0
  pushl $35
  105adf:	6a 23                	push   $0x23
  jmp alltraps
  105ae1:	e9 0a fa ff ff       	jmp    1054f0 <alltraps>

00105ae6 <vector36>:
.globl vector36
vector36:
  pushl $0
  105ae6:	6a 00                	push   $0x0
  pushl $36
  105ae8:	6a 24                	push   $0x24
  jmp alltraps
  105aea:	e9 01 fa ff ff       	jmp    1054f0 <alltraps>

00105aef <vector37>:
.globl vector37
vector37:
  pushl $0
  105aef:	6a 00                	push   $0x0
  pushl $37
  105af1:	6a 25                	push   $0x25
  jmp alltraps
  105af3:	e9 f8 f9 ff ff       	jmp    1054f0 <alltraps>

00105af8 <vector38>:
.globl vector38
vector38:
  pushl $0
  105af8:	6a 00                	push   $0x0
  pushl $38
  105afa:	6a 26                	push   $0x26
  jmp alltraps
  105afc:	e9 ef f9 ff ff       	jmp    1054f0 <alltraps>

00105b01 <vector39>:
.globl vector39
vector39:
  pushl $0
  105b01:	6a 00                	push   $0x0
  pushl $39
  105b03:	6a 27                	push   $0x27
  jmp alltraps
  105b05:	e9 e6 f9 ff ff       	jmp    1054f0 <alltraps>

00105b0a <vector40>:
.globl vector40
vector40:
  pushl $0
  105b0a:	6a 00                	push   $0x0
  pushl $40
  105b0c:	6a 28                	push   $0x28
  jmp alltraps
  105b0e:	e9 dd f9 ff ff       	jmp    1054f0 <alltraps>

00105b13 <vector41>:
.globl vector41
vector41:
  pushl $0
  105b13:	6a 00                	push   $0x0
  pushl $41
  105b15:	6a 29                	push   $0x29
  jmp alltraps
  105b17:	e9 d4 f9 ff ff       	jmp    1054f0 <alltraps>

00105b1c <vector42>:
.globl vector42
vector42:
  pushl $0
  105b1c:	6a 00                	push   $0x0
  pushl $42
  105b1e:	6a 2a                	push   $0x2a
  jmp alltraps
  105b20:	e9 cb f9 ff ff       	jmp    1054f0 <alltraps>

00105b25 <vector43>:
.globl vector43
vector43:
  pushl $0
  105b25:	6a 00                	push   $0x0
  pushl $43
  105b27:	6a 2b                	push   $0x2b
  jmp alltraps
  105b29:	e9 c2 f9 ff ff       	jmp    1054f0 <alltraps>

00105b2e <vector44>:
.globl vector44
vector44:
  pushl $0
  105b2e:	6a 00                	push   $0x0
  pushl $44
  105b30:	6a 2c                	push   $0x2c
  jmp alltraps
  105b32:	e9 b9 f9 ff ff       	jmp    1054f0 <alltraps>

00105b37 <vector45>:
.globl vector45
vector45:
  pushl $0
  105b37:	6a 00                	push   $0x0
  pushl $45
  105b39:	6a 2d                	push   $0x2d
  jmp alltraps
  105b3b:	e9 b0 f9 ff ff       	jmp    1054f0 <alltraps>

00105b40 <vector46>:
.globl vector46
vector46:
  pushl $0
  105b40:	6a 00                	push   $0x0
  pushl $46
  105b42:	6a 2e                	push   $0x2e
  jmp alltraps
  105b44:	e9 a7 f9 ff ff       	jmp    1054f0 <alltraps>

00105b49 <vector47>:
.globl vector47
vector47:
  pushl $0
  105b49:	6a 00                	push   $0x0
  pushl $47
  105b4b:	6a 2f                	push   $0x2f
  jmp alltraps
  105b4d:	e9 9e f9 ff ff       	jmp    1054f0 <alltraps>

00105b52 <vector48>:
.globl vector48
vector48:
  pushl $0
  105b52:	6a 00                	push   $0x0
  pushl $48
  105b54:	6a 30                	push   $0x30
  jmp alltraps
  105b56:	e9 95 f9 ff ff       	jmp    1054f0 <alltraps>

00105b5b <vector49>:
.globl vector49
vector49:
  pushl $0
  105b5b:	6a 00                	push   $0x0
  pushl $49
  105b5d:	6a 31                	push   $0x31
  jmp alltraps
  105b5f:	e9 8c f9 ff ff       	jmp    1054f0 <alltraps>

00105b64 <vector50>:
.globl vector50
vector50:
  pushl $0
  105b64:	6a 00                	push   $0x0
  pushl $50
  105b66:	6a 32                	push   $0x32
  jmp alltraps
  105b68:	e9 83 f9 ff ff       	jmp    1054f0 <alltraps>

00105b6d <vector51>:
.globl vector51
vector51:
  pushl $0
  105b6d:	6a 00                	push   $0x0
  pushl $51
  105b6f:	6a 33                	push   $0x33
  jmp alltraps
  105b71:	e9 7a f9 ff ff       	jmp    1054f0 <alltraps>

00105b76 <vector52>:
.globl vector52
vector52:
  pushl $0
  105b76:	6a 00                	push   $0x0
  pushl $52
  105b78:	6a 34                	push   $0x34
  jmp alltraps
  105b7a:	e9 71 f9 ff ff       	jmp    1054f0 <alltraps>

00105b7f <vector53>:
.globl vector53
vector53:
  pushl $0
  105b7f:	6a 00                	push   $0x0
  pushl $53
  105b81:	6a 35                	push   $0x35
  jmp alltraps
  105b83:	e9 68 f9 ff ff       	jmp    1054f0 <alltraps>

00105b88 <vector54>:
.globl vector54
vector54:
  pushl $0
  105b88:	6a 00                	push   $0x0
  pushl $54
  105b8a:	6a 36                	push   $0x36
  jmp alltraps
  105b8c:	e9 5f f9 ff ff       	jmp    1054f0 <alltraps>

00105b91 <vector55>:
.globl vector55
vector55:
  pushl $0
  105b91:	6a 00                	push   $0x0
  pushl $55
  105b93:	6a 37                	push   $0x37
  jmp alltraps
  105b95:	e9 56 f9 ff ff       	jmp    1054f0 <alltraps>

00105b9a <vector56>:
.globl vector56
vector56:
  pushl $0
  105b9a:	6a 00                	push   $0x0
  pushl $56
  105b9c:	6a 38                	push   $0x38
  jmp alltraps
  105b9e:	e9 4d f9 ff ff       	jmp    1054f0 <alltraps>

00105ba3 <vector57>:
.globl vector57
vector57:
  pushl $0
  105ba3:	6a 00                	push   $0x0
  pushl $57
  105ba5:	6a 39                	push   $0x39
  jmp alltraps
  105ba7:	e9 44 f9 ff ff       	jmp    1054f0 <alltraps>

00105bac <vector58>:
.globl vector58
vector58:
  pushl $0
  105bac:	6a 00                	push   $0x0
  pushl $58
  105bae:	6a 3a                	push   $0x3a
  jmp alltraps
  105bb0:	e9 3b f9 ff ff       	jmp    1054f0 <alltraps>

00105bb5 <vector59>:
.globl vector59
vector59:
  pushl $0
  105bb5:	6a 00                	push   $0x0
  pushl $59
  105bb7:	6a 3b                	push   $0x3b
  jmp alltraps
  105bb9:	e9 32 f9 ff ff       	jmp    1054f0 <alltraps>

00105bbe <vector60>:
.globl vector60
vector60:
  pushl $0
  105bbe:	6a 00                	push   $0x0
  pushl $60
  105bc0:	6a 3c                	push   $0x3c
  jmp alltraps
  105bc2:	e9 29 f9 ff ff       	jmp    1054f0 <alltraps>

00105bc7 <vector61>:
.globl vector61
vector61:
  pushl $0
  105bc7:	6a 00                	push   $0x0
  pushl $61
  105bc9:	6a 3d                	push   $0x3d
  jmp alltraps
  105bcb:	e9 20 f9 ff ff       	jmp    1054f0 <alltraps>

00105bd0 <vector62>:
.globl vector62
vector62:
  pushl $0
  105bd0:	6a 00                	push   $0x0
  pushl $62
  105bd2:	6a 3e                	push   $0x3e
  jmp alltraps
  105bd4:	e9 17 f9 ff ff       	jmp    1054f0 <alltraps>

00105bd9 <vector63>:
.globl vector63
vector63:
  pushl $0
  105bd9:	6a 00                	push   $0x0
  pushl $63
  105bdb:	6a 3f                	push   $0x3f
  jmp alltraps
  105bdd:	e9 0e f9 ff ff       	jmp    1054f0 <alltraps>

00105be2 <vector64>:
.globl vector64
vector64:
  pushl $0
  105be2:	6a 00                	push   $0x0
  pushl $64
  105be4:	6a 40                	push   $0x40
  jmp alltraps
  105be6:	e9 05 f9 ff ff       	jmp    1054f0 <alltraps>

00105beb <vector65>:
.globl vector65
vector65:
  pushl $0
  105beb:	6a 00                	push   $0x0
  pushl $65
  105bed:	6a 41                	push   $0x41
  jmp alltraps
  105bef:	e9 fc f8 ff ff       	jmp    1054f0 <alltraps>

00105bf4 <vector66>:
.globl vector66
vector66:
  pushl $0
  105bf4:	6a 00                	push   $0x0
  pushl $66
  105bf6:	6a 42                	push   $0x42
  jmp alltraps
  105bf8:	e9 f3 f8 ff ff       	jmp    1054f0 <alltraps>

00105bfd <vector67>:
.globl vector67
vector67:
  pushl $0
  105bfd:	6a 00                	push   $0x0
  pushl $67
  105bff:	6a 43                	push   $0x43
  jmp alltraps
  105c01:	e9 ea f8 ff ff       	jmp    1054f0 <alltraps>

00105c06 <vector68>:
.globl vector68
vector68:
  pushl $0
  105c06:	6a 00                	push   $0x0
  pushl $68
  105c08:	6a 44                	push   $0x44
  jmp alltraps
  105c0a:	e9 e1 f8 ff ff       	jmp    1054f0 <alltraps>

00105c0f <vector69>:
.globl vector69
vector69:
  pushl $0
  105c0f:	6a 00                	push   $0x0
  pushl $69
  105c11:	6a 45                	push   $0x45
  jmp alltraps
  105c13:	e9 d8 f8 ff ff       	jmp    1054f0 <alltraps>

00105c18 <vector70>:
.globl vector70
vector70:
  pushl $0
  105c18:	6a 00                	push   $0x0
  pushl $70
  105c1a:	6a 46                	push   $0x46
  jmp alltraps
  105c1c:	e9 cf f8 ff ff       	jmp    1054f0 <alltraps>

00105c21 <vector71>:
.globl vector71
vector71:
  pushl $0
  105c21:	6a 00                	push   $0x0
  pushl $71
  105c23:	6a 47                	push   $0x47
  jmp alltraps
  105c25:	e9 c6 f8 ff ff       	jmp    1054f0 <alltraps>

00105c2a <vector72>:
.globl vector72
vector72:
  pushl $0
  105c2a:	6a 00                	push   $0x0
  pushl $72
  105c2c:	6a 48                	push   $0x48
  jmp alltraps
  105c2e:	e9 bd f8 ff ff       	jmp    1054f0 <alltraps>

00105c33 <vector73>:
.globl vector73
vector73:
  pushl $0
  105c33:	6a 00                	push   $0x0
  pushl $73
  105c35:	6a 49                	push   $0x49
  jmp alltraps
  105c37:	e9 b4 f8 ff ff       	jmp    1054f0 <alltraps>

00105c3c <vector74>:
.globl vector74
vector74:
  pushl $0
  105c3c:	6a 00                	push   $0x0
  pushl $74
  105c3e:	6a 4a                	push   $0x4a
  jmp alltraps
  105c40:	e9 ab f8 ff ff       	jmp    1054f0 <alltraps>

00105c45 <vector75>:
.globl vector75
vector75:
  pushl $0
  105c45:	6a 00                	push   $0x0
  pushl $75
  105c47:	6a 4b                	push   $0x4b
  jmp alltraps
  105c49:	e9 a2 f8 ff ff       	jmp    1054f0 <alltraps>

00105c4e <vector76>:
.globl vector76
vector76:
  pushl $0
  105c4e:	6a 00                	push   $0x0
  pushl $76
  105c50:	6a 4c                	push   $0x4c
  jmp alltraps
  105c52:	e9 99 f8 ff ff       	jmp    1054f0 <alltraps>

00105c57 <vector77>:
.globl vector77
vector77:
  pushl $0
  105c57:	6a 00                	push   $0x0
  pushl $77
  105c59:	6a 4d                	push   $0x4d
  jmp alltraps
  105c5b:	e9 90 f8 ff ff       	jmp    1054f0 <alltraps>

00105c60 <vector78>:
.globl vector78
vector78:
  pushl $0
  105c60:	6a 00                	push   $0x0
  pushl $78
  105c62:	6a 4e                	push   $0x4e
  jmp alltraps
  105c64:	e9 87 f8 ff ff       	jmp    1054f0 <alltraps>

00105c69 <vector79>:
.globl vector79
vector79:
  pushl $0
  105c69:	6a 00                	push   $0x0
  pushl $79
  105c6b:	6a 4f                	push   $0x4f
  jmp alltraps
  105c6d:	e9 7e f8 ff ff       	jmp    1054f0 <alltraps>

00105c72 <vector80>:
.globl vector80
vector80:
  pushl $0
  105c72:	6a 00                	push   $0x0
  pushl $80
  105c74:	6a 50                	push   $0x50
  jmp alltraps
  105c76:	e9 75 f8 ff ff       	jmp    1054f0 <alltraps>

00105c7b <vector81>:
.globl vector81
vector81:
  pushl $0
  105c7b:	6a 00                	push   $0x0
  pushl $81
  105c7d:	6a 51                	push   $0x51
  jmp alltraps
  105c7f:	e9 6c f8 ff ff       	jmp    1054f0 <alltraps>

00105c84 <vector82>:
.globl vector82
vector82:
  pushl $0
  105c84:	6a 00                	push   $0x0
  pushl $82
  105c86:	6a 52                	push   $0x52
  jmp alltraps
  105c88:	e9 63 f8 ff ff       	jmp    1054f0 <alltraps>

00105c8d <vector83>:
.globl vector83
vector83:
  pushl $0
  105c8d:	6a 00                	push   $0x0
  pushl $83
  105c8f:	6a 53                	push   $0x53
  jmp alltraps
  105c91:	e9 5a f8 ff ff       	jmp    1054f0 <alltraps>

00105c96 <vector84>:
.globl vector84
vector84:
  pushl $0
  105c96:	6a 00                	push   $0x0
  pushl $84
  105c98:	6a 54                	push   $0x54
  jmp alltraps
  105c9a:	e9 51 f8 ff ff       	jmp    1054f0 <alltraps>

00105c9f <vector85>:
.globl vector85
vector85:
  pushl $0
  105c9f:	6a 00                	push   $0x0
  pushl $85
  105ca1:	6a 55                	push   $0x55
  jmp alltraps
  105ca3:	e9 48 f8 ff ff       	jmp    1054f0 <alltraps>

00105ca8 <vector86>:
.globl vector86
vector86:
  pushl $0
  105ca8:	6a 00                	push   $0x0
  pushl $86
  105caa:	6a 56                	push   $0x56
  jmp alltraps
  105cac:	e9 3f f8 ff ff       	jmp    1054f0 <alltraps>

00105cb1 <vector87>:
.globl vector87
vector87:
  pushl $0
  105cb1:	6a 00                	push   $0x0
  pushl $87
  105cb3:	6a 57                	push   $0x57
  jmp alltraps
  105cb5:	e9 36 f8 ff ff       	jmp    1054f0 <alltraps>

00105cba <vector88>:
.globl vector88
vector88:
  pushl $0
  105cba:	6a 00                	push   $0x0
  pushl $88
  105cbc:	6a 58                	push   $0x58
  jmp alltraps
  105cbe:	e9 2d f8 ff ff       	jmp    1054f0 <alltraps>

00105cc3 <vector89>:
.globl vector89
vector89:
  pushl $0
  105cc3:	6a 00                	push   $0x0
  pushl $89
  105cc5:	6a 59                	push   $0x59
  jmp alltraps
  105cc7:	e9 24 f8 ff ff       	jmp    1054f0 <alltraps>

00105ccc <vector90>:
.globl vector90
vector90:
  pushl $0
  105ccc:	6a 00                	push   $0x0
  pushl $90
  105cce:	6a 5a                	push   $0x5a
  jmp alltraps
  105cd0:	e9 1b f8 ff ff       	jmp    1054f0 <alltraps>

00105cd5 <vector91>:
.globl vector91
vector91:
  pushl $0
  105cd5:	6a 00                	push   $0x0
  pushl $91
  105cd7:	6a 5b                	push   $0x5b
  jmp alltraps
  105cd9:	e9 12 f8 ff ff       	jmp    1054f0 <alltraps>

00105cde <vector92>:
.globl vector92
vector92:
  pushl $0
  105cde:	6a 00                	push   $0x0
  pushl $92
  105ce0:	6a 5c                	push   $0x5c
  jmp alltraps
  105ce2:	e9 09 f8 ff ff       	jmp    1054f0 <alltraps>

00105ce7 <vector93>:
.globl vector93
vector93:
  pushl $0
  105ce7:	6a 00                	push   $0x0
  pushl $93
  105ce9:	6a 5d                	push   $0x5d
  jmp alltraps
  105ceb:	e9 00 f8 ff ff       	jmp    1054f0 <alltraps>

00105cf0 <vector94>:
.globl vector94
vector94:
  pushl $0
  105cf0:	6a 00                	push   $0x0
  pushl $94
  105cf2:	6a 5e                	push   $0x5e
  jmp alltraps
  105cf4:	e9 f7 f7 ff ff       	jmp    1054f0 <alltraps>

00105cf9 <vector95>:
.globl vector95
vector95:
  pushl $0
  105cf9:	6a 00                	push   $0x0
  pushl $95
  105cfb:	6a 5f                	push   $0x5f
  jmp alltraps
  105cfd:	e9 ee f7 ff ff       	jmp    1054f0 <alltraps>

00105d02 <vector96>:
.globl vector96
vector96:
  pushl $0
  105d02:	6a 00                	push   $0x0
  pushl $96
  105d04:	6a 60                	push   $0x60
  jmp alltraps
  105d06:	e9 e5 f7 ff ff       	jmp    1054f0 <alltraps>

00105d0b <vector97>:
.globl vector97
vector97:
  pushl $0
  105d0b:	6a 00                	push   $0x0
  pushl $97
  105d0d:	6a 61                	push   $0x61
  jmp alltraps
  105d0f:	e9 dc f7 ff ff       	jmp    1054f0 <alltraps>

00105d14 <vector98>:
.globl vector98
vector98:
  pushl $0
  105d14:	6a 00                	push   $0x0
  pushl $98
  105d16:	6a 62                	push   $0x62
  jmp alltraps
  105d18:	e9 d3 f7 ff ff       	jmp    1054f0 <alltraps>

00105d1d <vector99>:
.globl vector99
vector99:
  pushl $0
  105d1d:	6a 00                	push   $0x0
  pushl $99
  105d1f:	6a 63                	push   $0x63
  jmp alltraps
  105d21:	e9 ca f7 ff ff       	jmp    1054f0 <alltraps>

00105d26 <vector100>:
.globl vector100
vector100:
  pushl $0
  105d26:	6a 00                	push   $0x0
  pushl $100
  105d28:	6a 64                	push   $0x64
  jmp alltraps
  105d2a:	e9 c1 f7 ff ff       	jmp    1054f0 <alltraps>

00105d2f <vector101>:
.globl vector101
vector101:
  pushl $0
  105d2f:	6a 00                	push   $0x0
  pushl $101
  105d31:	6a 65                	push   $0x65
  jmp alltraps
  105d33:	e9 b8 f7 ff ff       	jmp    1054f0 <alltraps>

00105d38 <vector102>:
.globl vector102
vector102:
  pushl $0
  105d38:	6a 00                	push   $0x0
  pushl $102
  105d3a:	6a 66                	push   $0x66
  jmp alltraps
  105d3c:	e9 af f7 ff ff       	jmp    1054f0 <alltraps>

00105d41 <vector103>:
.globl vector103
vector103:
  pushl $0
  105d41:	6a 00                	push   $0x0
  pushl $103
  105d43:	6a 67                	push   $0x67
  jmp alltraps
  105d45:	e9 a6 f7 ff ff       	jmp    1054f0 <alltraps>

00105d4a <vector104>:
.globl vector104
vector104:
  pushl $0
  105d4a:	6a 00                	push   $0x0
  pushl $104
  105d4c:	6a 68                	push   $0x68
  jmp alltraps
  105d4e:	e9 9d f7 ff ff       	jmp    1054f0 <alltraps>

00105d53 <vector105>:
.globl vector105
vector105:
  pushl $0
  105d53:	6a 00                	push   $0x0
  pushl $105
  105d55:	6a 69                	push   $0x69
  jmp alltraps
  105d57:	e9 94 f7 ff ff       	jmp    1054f0 <alltraps>

00105d5c <vector106>:
.globl vector106
vector106:
  pushl $0
  105d5c:	6a 00                	push   $0x0
  pushl $106
  105d5e:	6a 6a                	push   $0x6a
  jmp alltraps
  105d60:	e9 8b f7 ff ff       	jmp    1054f0 <alltraps>

00105d65 <vector107>:
.globl vector107
vector107:
  pushl $0
  105d65:	6a 00                	push   $0x0
  pushl $107
  105d67:	6a 6b                	push   $0x6b
  jmp alltraps
  105d69:	e9 82 f7 ff ff       	jmp    1054f0 <alltraps>

00105d6e <vector108>:
.globl vector108
vector108:
  pushl $0
  105d6e:	6a 00                	push   $0x0
  pushl $108
  105d70:	6a 6c                	push   $0x6c
  jmp alltraps
  105d72:	e9 79 f7 ff ff       	jmp    1054f0 <alltraps>

00105d77 <vector109>:
.globl vector109
vector109:
  pushl $0
  105d77:	6a 00                	push   $0x0
  pushl $109
  105d79:	6a 6d                	push   $0x6d
  jmp alltraps
  105d7b:	e9 70 f7 ff ff       	jmp    1054f0 <alltraps>

00105d80 <vector110>:
.globl vector110
vector110:
  pushl $0
  105d80:	6a 00                	push   $0x0
  pushl $110
  105d82:	6a 6e                	push   $0x6e
  jmp alltraps
  105d84:	e9 67 f7 ff ff       	jmp    1054f0 <alltraps>

00105d89 <vector111>:
.globl vector111
vector111:
  pushl $0
  105d89:	6a 00                	push   $0x0
  pushl $111
  105d8b:	6a 6f                	push   $0x6f
  jmp alltraps
  105d8d:	e9 5e f7 ff ff       	jmp    1054f0 <alltraps>

00105d92 <vector112>:
.globl vector112
vector112:
  pushl $0
  105d92:	6a 00                	push   $0x0
  pushl $112
  105d94:	6a 70                	push   $0x70
  jmp alltraps
  105d96:	e9 55 f7 ff ff       	jmp    1054f0 <alltraps>

00105d9b <vector113>:
.globl vector113
vector113:
  pushl $0
  105d9b:	6a 00                	push   $0x0
  pushl $113
  105d9d:	6a 71                	push   $0x71
  jmp alltraps
  105d9f:	e9 4c f7 ff ff       	jmp    1054f0 <alltraps>

00105da4 <vector114>:
.globl vector114
vector114:
  pushl $0
  105da4:	6a 00                	push   $0x0
  pushl $114
  105da6:	6a 72                	push   $0x72
  jmp alltraps
  105da8:	e9 43 f7 ff ff       	jmp    1054f0 <alltraps>

00105dad <vector115>:
.globl vector115
vector115:
  pushl $0
  105dad:	6a 00                	push   $0x0
  pushl $115
  105daf:	6a 73                	push   $0x73
  jmp alltraps
  105db1:	e9 3a f7 ff ff       	jmp    1054f0 <alltraps>

00105db6 <vector116>:
.globl vector116
vector116:
  pushl $0
  105db6:	6a 00                	push   $0x0
  pushl $116
  105db8:	6a 74                	push   $0x74
  jmp alltraps
  105dba:	e9 31 f7 ff ff       	jmp    1054f0 <alltraps>

00105dbf <vector117>:
.globl vector117
vector117:
  pushl $0
  105dbf:	6a 00                	push   $0x0
  pushl $117
  105dc1:	6a 75                	push   $0x75
  jmp alltraps
  105dc3:	e9 28 f7 ff ff       	jmp    1054f0 <alltraps>

00105dc8 <vector118>:
.globl vector118
vector118:
  pushl $0
  105dc8:	6a 00                	push   $0x0
  pushl $118
  105dca:	6a 76                	push   $0x76
  jmp alltraps
  105dcc:	e9 1f f7 ff ff       	jmp    1054f0 <alltraps>

00105dd1 <vector119>:
.globl vector119
vector119:
  pushl $0
  105dd1:	6a 00                	push   $0x0
  pushl $119
  105dd3:	6a 77                	push   $0x77
  jmp alltraps
  105dd5:	e9 16 f7 ff ff       	jmp    1054f0 <alltraps>

00105dda <vector120>:
.globl vector120
vector120:
  pushl $0
  105dda:	6a 00                	push   $0x0
  pushl $120
  105ddc:	6a 78                	push   $0x78
  jmp alltraps
  105dde:	e9 0d f7 ff ff       	jmp    1054f0 <alltraps>

00105de3 <vector121>:
.globl vector121
vector121:
  pushl $0
  105de3:	6a 00                	push   $0x0
  pushl $121
  105de5:	6a 79                	push   $0x79
  jmp alltraps
  105de7:	e9 04 f7 ff ff       	jmp    1054f0 <alltraps>

00105dec <vector122>:
.globl vector122
vector122:
  pushl $0
  105dec:	6a 00                	push   $0x0
  pushl $122
  105dee:	6a 7a                	push   $0x7a
  jmp alltraps
  105df0:	e9 fb f6 ff ff       	jmp    1054f0 <alltraps>

00105df5 <vector123>:
.globl vector123
vector123:
  pushl $0
  105df5:	6a 00                	push   $0x0
  pushl $123
  105df7:	6a 7b                	push   $0x7b
  jmp alltraps
  105df9:	e9 f2 f6 ff ff       	jmp    1054f0 <alltraps>

00105dfe <vector124>:
.globl vector124
vector124:
  pushl $0
  105dfe:	6a 00                	push   $0x0
  pushl $124
  105e00:	6a 7c                	push   $0x7c
  jmp alltraps
  105e02:	e9 e9 f6 ff ff       	jmp    1054f0 <alltraps>

00105e07 <vector125>:
.globl vector125
vector125:
  pushl $0
  105e07:	6a 00                	push   $0x0
  pushl $125
  105e09:	6a 7d                	push   $0x7d
  jmp alltraps
  105e0b:	e9 e0 f6 ff ff       	jmp    1054f0 <alltraps>

00105e10 <vector126>:
.globl vector126
vector126:
  pushl $0
  105e10:	6a 00                	push   $0x0
  pushl $126
  105e12:	6a 7e                	push   $0x7e
  jmp alltraps
  105e14:	e9 d7 f6 ff ff       	jmp    1054f0 <alltraps>

00105e19 <vector127>:
.globl vector127
vector127:
  pushl $0
  105e19:	6a 00                	push   $0x0
  pushl $127
  105e1b:	6a 7f                	push   $0x7f
  jmp alltraps
  105e1d:	e9 ce f6 ff ff       	jmp    1054f0 <alltraps>

00105e22 <vector128>:
.globl vector128
vector128:
  pushl $0
  105e22:	6a 00                	push   $0x0
  pushl $128
  105e24:	68 80 00 00 00       	push   $0x80
  jmp alltraps
  105e29:	e9 c2 f6 ff ff       	jmp    1054f0 <alltraps>

00105e2e <vector129>:
.globl vector129
vector129:
  pushl $0
  105e2e:	6a 00                	push   $0x0
  pushl $129
  105e30:	68 81 00 00 00       	push   $0x81
  jmp alltraps
  105e35:	e9 b6 f6 ff ff       	jmp    1054f0 <alltraps>

00105e3a <vector130>:
.globl vector130
vector130:
  pushl $0
  105e3a:	6a 00                	push   $0x0
  pushl $130
  105e3c:	68 82 00 00 00       	push   $0x82
  jmp alltraps
  105e41:	e9 aa f6 ff ff       	jmp    1054f0 <alltraps>

00105e46 <vector131>:
.globl vector131
vector131:
  pushl $0
  105e46:	6a 00                	push   $0x0
  pushl $131
  105e48:	68 83 00 00 00       	push   $0x83
  jmp alltraps
  105e4d:	e9 9e f6 ff ff       	jmp    1054f0 <alltraps>

00105e52 <vector132>:
.globl vector132
vector132:
  pushl $0
  105e52:	6a 00                	push   $0x0
  pushl $132
  105e54:	68 84 00 00 00       	push   $0x84
  jmp alltraps
  105e59:	e9 92 f6 ff ff       	jmp    1054f0 <alltraps>

00105e5e <vector133>:
.globl vector133
vector133:
  pushl $0
  105e5e:	6a 00                	push   $0x0
  pushl $133
  105e60:	68 85 00 00 00       	push   $0x85
  jmp alltraps
  105e65:	e9 86 f6 ff ff       	jmp    1054f0 <alltraps>

00105e6a <vector134>:
.globl vector134
vector134:
  pushl $0
  105e6a:	6a 00                	push   $0x0
  pushl $134
  105e6c:	68 86 00 00 00       	push   $0x86
  jmp alltraps
  105e71:	e9 7a f6 ff ff       	jmp    1054f0 <alltraps>

00105e76 <vector135>:
.globl vector135
vector135:
  pushl $0
  105e76:	6a 00                	push   $0x0
  pushl $135
  105e78:	68 87 00 00 00       	push   $0x87
  jmp alltraps
  105e7d:	e9 6e f6 ff ff       	jmp    1054f0 <alltraps>

00105e82 <vector136>:
.globl vector136
vector136:
  pushl $0
  105e82:	6a 00                	push   $0x0
  pushl $136
  105e84:	68 88 00 00 00       	push   $0x88
  jmp alltraps
  105e89:	e9 62 f6 ff ff       	jmp    1054f0 <alltraps>

00105e8e <vector137>:
.globl vector137
vector137:
  pushl $0
  105e8e:	6a 00                	push   $0x0
  pushl $137
  105e90:	68 89 00 00 00       	push   $0x89
  jmp alltraps
  105e95:	e9 56 f6 ff ff       	jmp    1054f0 <alltraps>

00105e9a <vector138>:
.globl vector138
vector138:
  pushl $0
  105e9a:	6a 00                	push   $0x0
  pushl $138
  105e9c:	68 8a 00 00 00       	push   $0x8a
  jmp alltraps
  105ea1:	e9 4a f6 ff ff       	jmp    1054f0 <alltraps>

00105ea6 <vector139>:
.globl vector139
vector139:
  pushl $0
  105ea6:	6a 00                	push   $0x0
  pushl $139
  105ea8:	68 8b 00 00 00       	push   $0x8b
  jmp alltraps
  105ead:	e9 3e f6 ff ff       	jmp    1054f0 <alltraps>

00105eb2 <vector140>:
.globl vector140
vector140:
  pushl $0
  105eb2:	6a 00                	push   $0x0
  pushl $140
  105eb4:	68 8c 00 00 00       	push   $0x8c
  jmp alltraps
  105eb9:	e9 32 f6 ff ff       	jmp    1054f0 <alltraps>

00105ebe <vector141>:
.globl vector141
vector141:
  pushl $0
  105ebe:	6a 00                	push   $0x0
  pushl $141
  105ec0:	68 8d 00 00 00       	push   $0x8d
  jmp alltraps
  105ec5:	e9 26 f6 ff ff       	jmp    1054f0 <alltraps>

00105eca <vector142>:
.globl vector142
vector142:
  pushl $0
  105eca:	6a 00                	push   $0x0
  pushl $142
  105ecc:	68 8e 00 00 00       	push   $0x8e
  jmp alltraps
  105ed1:	e9 1a f6 ff ff       	jmp    1054f0 <alltraps>

00105ed6 <vector143>:
.globl vector143
vector143:
  pushl $0
  105ed6:	6a 00                	push   $0x0
  pushl $143
  105ed8:	68 8f 00 00 00       	push   $0x8f
  jmp alltraps
  105edd:	e9 0e f6 ff ff       	jmp    1054f0 <alltraps>

00105ee2 <vector144>:
.globl vector144
vector144:
  pushl $0
  105ee2:	6a 00                	push   $0x0
  pushl $144
  105ee4:	68 90 00 00 00       	push   $0x90
  jmp alltraps
  105ee9:	e9 02 f6 ff ff       	jmp    1054f0 <alltraps>

00105eee <vector145>:
.globl vector145
vector145:
  pushl $0
  105eee:	6a 00                	push   $0x0
  pushl $145
  105ef0:	68 91 00 00 00       	push   $0x91
  jmp alltraps
  105ef5:	e9 f6 f5 ff ff       	jmp    1054f0 <alltraps>

00105efa <vector146>:
.globl vector146
vector146:
  pushl $0
  105efa:	6a 00                	push   $0x0
  pushl $146
  105efc:	68 92 00 00 00       	push   $0x92
  jmp alltraps
  105f01:	e9 ea f5 ff ff       	jmp    1054f0 <alltraps>

00105f06 <vector147>:
.globl vector147
vector147:
  pushl $0
  105f06:	6a 00                	push   $0x0
  pushl $147
  105f08:	68 93 00 00 00       	push   $0x93
  jmp alltraps
  105f0d:	e9 de f5 ff ff       	jmp    1054f0 <alltraps>

00105f12 <vector148>:
.globl vector148
vector148:
  pushl $0
  105f12:	6a 00                	push   $0x0
  pushl $148
  105f14:	68 94 00 00 00       	push   $0x94
  jmp alltraps
  105f19:	e9 d2 f5 ff ff       	jmp    1054f0 <alltraps>

00105f1e <vector149>:
.globl vector149
vector149:
  pushl $0
  105f1e:	6a 00                	push   $0x0
  pushl $149
  105f20:	68 95 00 00 00       	push   $0x95
  jmp alltraps
  105f25:	e9 c6 f5 ff ff       	jmp    1054f0 <alltraps>

00105f2a <vector150>:
.globl vector150
vector150:
  pushl $0
  105f2a:	6a 00                	push   $0x0
  pushl $150
  105f2c:	68 96 00 00 00       	push   $0x96
  jmp alltraps
  105f31:	e9 ba f5 ff ff       	jmp    1054f0 <alltraps>

00105f36 <vector151>:
.globl vector151
vector151:
  pushl $0
  105f36:	6a 00                	push   $0x0
  pushl $151
  105f38:	68 97 00 00 00       	push   $0x97
  jmp alltraps
  105f3d:	e9 ae f5 ff ff       	jmp    1054f0 <alltraps>

00105f42 <vector152>:
.globl vector152
vector152:
  pushl $0
  105f42:	6a 00                	push   $0x0
  pushl $152
  105f44:	68 98 00 00 00       	push   $0x98
  jmp alltraps
  105f49:	e9 a2 f5 ff ff       	jmp    1054f0 <alltraps>

00105f4e <vector153>:
.globl vector153
vector153:
  pushl $0
  105f4e:	6a 00                	push   $0x0
  pushl $153
  105f50:	68 99 00 00 00       	push   $0x99
  jmp alltraps
  105f55:	e9 96 f5 ff ff       	jmp    1054f0 <alltraps>

00105f5a <vector154>:
.globl vector154
vector154:
  pushl $0
  105f5a:	6a 00                	push   $0x0
  pushl $154
  105f5c:	68 9a 00 00 00       	push   $0x9a
  jmp alltraps
  105f61:	e9 8a f5 ff ff       	jmp    1054f0 <alltraps>

00105f66 <vector155>:
.globl vector155
vector155:
  pushl $0
  105f66:	6a 00                	push   $0x0
  pushl $155
  105f68:	68 9b 00 00 00       	push   $0x9b
  jmp alltraps
  105f6d:	e9 7e f5 ff ff       	jmp    1054f0 <alltraps>

00105f72 <vector156>:
.globl vector156
vector156:
  pushl $0
  105f72:	6a 00                	push   $0x0
  pushl $156
  105f74:	68 9c 00 00 00       	push   $0x9c
  jmp alltraps
  105f79:	e9 72 f5 ff ff       	jmp    1054f0 <alltraps>

00105f7e <vector157>:
.globl vector157
vector157:
  pushl $0
  105f7e:	6a 00                	push   $0x0
  pushl $157
  105f80:	68 9d 00 00 00       	push   $0x9d
  jmp alltraps
  105f85:	e9 66 f5 ff ff       	jmp    1054f0 <alltraps>

00105f8a <vector158>:
.globl vector158
vector158:
  pushl $0
  105f8a:	6a 00                	push   $0x0
  pushl $158
  105f8c:	68 9e 00 00 00       	push   $0x9e
  jmp alltraps
  105f91:	e9 5a f5 ff ff       	jmp    1054f0 <alltraps>

00105f96 <vector159>:
.globl vector159
vector159:
  pushl $0
  105f96:	6a 00                	push   $0x0
  pushl $159
  105f98:	68 9f 00 00 00       	push   $0x9f
  jmp alltraps
  105f9d:	e9 4e f5 ff ff       	jmp    1054f0 <alltraps>

00105fa2 <vector160>:
.globl vector160
vector160:
  pushl $0
  105fa2:	6a 00                	push   $0x0
  pushl $160
  105fa4:	68 a0 00 00 00       	push   $0xa0
  jmp alltraps
  105fa9:	e9 42 f5 ff ff       	jmp    1054f0 <alltraps>

00105fae <vector161>:
.globl vector161
vector161:
  pushl $0
  105fae:	6a 00                	push   $0x0
  pushl $161
  105fb0:	68 a1 00 00 00       	push   $0xa1
  jmp alltraps
  105fb5:	e9 36 f5 ff ff       	jmp    1054f0 <alltraps>

00105fba <vector162>:
.globl vector162
vector162:
  pushl $0
  105fba:	6a 00                	push   $0x0
  pushl $162
  105fbc:	68 a2 00 00 00       	push   $0xa2
  jmp alltraps
  105fc1:	e9 2a f5 ff ff       	jmp    1054f0 <alltraps>

00105fc6 <vector163>:
.globl vector163
vector163:
  pushl $0
  105fc6:	6a 00                	push   $0x0
  pushl $163
  105fc8:	68 a3 00 00 00       	push   $0xa3
  jmp alltraps
  105fcd:	e9 1e f5 ff ff       	jmp    1054f0 <alltraps>

00105fd2 <vector164>:
.globl vector164
vector164:
  pushl $0
  105fd2:	6a 00                	push   $0x0
  pushl $164
  105fd4:	68 a4 00 00 00       	push   $0xa4
  jmp alltraps
  105fd9:	e9 12 f5 ff ff       	jmp    1054f0 <alltraps>

00105fde <vector165>:
.globl vector165
vector165:
  pushl $0
  105fde:	6a 00                	push   $0x0
  pushl $165
  105fe0:	68 a5 00 00 00       	push   $0xa5
  jmp alltraps
  105fe5:	e9 06 f5 ff ff       	jmp    1054f0 <alltraps>

00105fea <vector166>:
.globl vector166
vector166:
  pushl $0
  105fea:	6a 00                	push   $0x0
  pushl $166
  105fec:	68 a6 00 00 00       	push   $0xa6
  jmp alltraps
  105ff1:	e9 fa f4 ff ff       	jmp    1054f0 <alltraps>

00105ff6 <vector167>:
.globl vector167
vector167:
  pushl $0
  105ff6:	6a 00                	push   $0x0
  pushl $167
  105ff8:	68 a7 00 00 00       	push   $0xa7
  jmp alltraps
  105ffd:	e9 ee f4 ff ff       	jmp    1054f0 <alltraps>

00106002 <vector168>:
.globl vector168
vector168:
  pushl $0
  106002:	6a 00                	push   $0x0
  pushl $168
  106004:	68 a8 00 00 00       	push   $0xa8
  jmp alltraps
  106009:	e9 e2 f4 ff ff       	jmp    1054f0 <alltraps>

0010600e <vector169>:
.globl vector169
vector169:
  pushl $0
  10600e:	6a 00                	push   $0x0
  pushl $169
  106010:	68 a9 00 00 00       	push   $0xa9
  jmp alltraps
  106015:	e9 d6 f4 ff ff       	jmp    1054f0 <alltraps>

0010601a <vector170>:
.globl vector170
vector170:
  pushl $0
  10601a:	6a 00                	push   $0x0
  pushl $170
  10601c:	68 aa 00 00 00       	push   $0xaa
  jmp alltraps
  106021:	e9 ca f4 ff ff       	jmp    1054f0 <alltraps>

00106026 <vector171>:
.globl vector171
vector171:
  pushl $0
  106026:	6a 00                	push   $0x0
  pushl $171
  106028:	68 ab 00 00 00       	push   $0xab
  jmp alltraps
  10602d:	e9 be f4 ff ff       	jmp    1054f0 <alltraps>

00106032 <vector172>:
.globl vector172
vector172:
  pushl $0
  106032:	6a 00                	push   $0x0
  pushl $172
  106034:	68 ac 00 00 00       	push   $0xac
  jmp alltraps
  106039:	e9 b2 f4 ff ff       	jmp    1054f0 <alltraps>

0010603e <vector173>:
.globl vector173
vector173:
  pushl $0
  10603e:	6a 00                	push   $0x0
  pushl $173
  106040:	68 ad 00 00 00       	push   $0xad
  jmp alltraps
  106045:	e9 a6 f4 ff ff       	jmp    1054f0 <alltraps>

0010604a <vector174>:
.globl vector174
vector174:
  pushl $0
  10604a:	6a 00                	push   $0x0
  pushl $174
  10604c:	68 ae 00 00 00       	push   $0xae
  jmp alltraps
  106051:	e9 9a f4 ff ff       	jmp    1054f0 <alltraps>

00106056 <vector175>:
.globl vector175
vector175:
  pushl $0
  106056:	6a 00                	push   $0x0
  pushl $175
  106058:	68 af 00 00 00       	push   $0xaf
  jmp alltraps
  10605d:	e9 8e f4 ff ff       	jmp    1054f0 <alltraps>

00106062 <vector176>:
.globl vector176
vector176:
  pushl $0
  106062:	6a 00                	push   $0x0
  pushl $176
  106064:	68 b0 00 00 00       	push   $0xb0
  jmp alltraps
  106069:	e9 82 f4 ff ff       	jmp    1054f0 <alltraps>

0010606e <vector177>:
.globl vector177
vector177:
  pushl $0
  10606e:	6a 00                	push   $0x0
  pushl $177
  106070:	68 b1 00 00 00       	push   $0xb1
  jmp alltraps
  106075:	e9 76 f4 ff ff       	jmp    1054f0 <alltraps>

0010607a <vector178>:
.globl vector178
vector178:
  pushl $0
  10607a:	6a 00                	push   $0x0
  pushl $178
  10607c:	68 b2 00 00 00       	push   $0xb2
  jmp alltraps
  106081:	e9 6a f4 ff ff       	jmp    1054f0 <alltraps>

00106086 <vector179>:
.globl vector179
vector179:
  pushl $0
  106086:	6a 00                	push   $0x0
  pushl $179
  106088:	68 b3 00 00 00       	push   $0xb3
  jmp alltraps
  10608d:	e9 5e f4 ff ff       	jmp    1054f0 <alltraps>

00106092 <vector180>:
.globl vector180
vector180:
  pushl $0
  106092:	6a 00                	push   $0x0
  pushl $180
  106094:	68 b4 00 00 00       	push   $0xb4
  jmp alltraps
  106099:	e9 52 f4 ff ff       	jmp    1054f0 <alltraps>

0010609e <vector181>:
.globl vector181
vector181:
  pushl $0
  10609e:	6a 00                	push   $0x0
  pushl $181
  1060a0:	68 b5 00 00 00       	push   $0xb5
  jmp alltraps
  1060a5:	e9 46 f4 ff ff       	jmp    1054f0 <alltraps>

001060aa <vector182>:
.globl vector182
vector182:
  pushl $0
  1060aa:	6a 00                	push   $0x0
  pushl $182
  1060ac:	68 b6 00 00 00       	push   $0xb6
  jmp alltraps
  1060b1:	e9 3a f4 ff ff       	jmp    1054f0 <alltraps>

001060b6 <vector183>:
.globl vector183
vector183:
  pushl $0
  1060b6:	6a 00                	push   $0x0
  pushl $183
  1060b8:	68 b7 00 00 00       	push   $0xb7
  jmp alltraps
  1060bd:	e9 2e f4 ff ff       	jmp    1054f0 <alltraps>

001060c2 <vector184>:
.globl vector184
vector184:
  pushl $0
  1060c2:	6a 00                	push   $0x0
  pushl $184
  1060c4:	68 b8 00 00 00       	push   $0xb8
  jmp alltraps
  1060c9:	e9 22 f4 ff ff       	jmp    1054f0 <alltraps>

001060ce <vector185>:
.globl vector185
vector185:
  pushl $0
  1060ce:	6a 00                	push   $0x0
  pushl $185
  1060d0:	68 b9 00 00 00       	push   $0xb9
  jmp alltraps
  1060d5:	e9 16 f4 ff ff       	jmp    1054f0 <alltraps>

001060da <vector186>:
.globl vector186
vector186:
  pushl $0
  1060da:	6a 00                	push   $0x0
  pushl $186
  1060dc:	68 ba 00 00 00       	push   $0xba
  jmp alltraps
  1060e1:	e9 0a f4 ff ff       	jmp    1054f0 <alltraps>

001060e6 <vector187>:
.globl vector187
vector187:
  pushl $0
  1060e6:	6a 00                	push   $0x0
  pushl $187
  1060e8:	68 bb 00 00 00       	push   $0xbb
  jmp alltraps
  1060ed:	e9 fe f3 ff ff       	jmp    1054f0 <alltraps>

001060f2 <vector188>:
.globl vector188
vector188:
  pushl $0
  1060f2:	6a 00                	push   $0x0
  pushl $188
  1060f4:	68 bc 00 00 00       	push   $0xbc
  jmp alltraps
  1060f9:	e9 f2 f3 ff ff       	jmp    1054f0 <alltraps>

001060fe <vector189>:
.globl vector189
vector189:
  pushl $0
  1060fe:	6a 00                	push   $0x0
  pushl $189
  106100:	68 bd 00 00 00       	push   $0xbd
  jmp alltraps
  106105:	e9 e6 f3 ff ff       	jmp    1054f0 <alltraps>

0010610a <vector190>:
.globl vector190
vector190:
  pushl $0
  10610a:	6a 00                	push   $0x0
  pushl $190
  10610c:	68 be 00 00 00       	push   $0xbe
  jmp alltraps
  106111:	e9 da f3 ff ff       	jmp    1054f0 <alltraps>

00106116 <vector191>:
.globl vector191
vector191:
  pushl $0
  106116:	6a 00                	push   $0x0
  pushl $191
  106118:	68 bf 00 00 00       	push   $0xbf
  jmp alltraps
  10611d:	e9 ce f3 ff ff       	jmp    1054f0 <alltraps>

00106122 <vector192>:
.globl vector192
vector192:
  pushl $0
  106122:	6a 00                	push   $0x0
  pushl $192
  106124:	68 c0 00 00 00       	push   $0xc0
  jmp alltraps
  106129:	e9 c2 f3 ff ff       	jmp    1054f0 <alltraps>

0010612e <vector193>:
.globl vector193
vector193:
  pushl $0
  10612e:	6a 00                	push   $0x0
  pushl $193
  106130:	68 c1 00 00 00       	push   $0xc1
  jmp alltraps
  106135:	e9 b6 f3 ff ff       	jmp    1054f0 <alltraps>

0010613a <vector194>:
.globl vector194
vector194:
  pushl $0
  10613a:	6a 00                	push   $0x0
  pushl $194
  10613c:	68 c2 00 00 00       	push   $0xc2
  jmp alltraps
  106141:	e9 aa f3 ff ff       	jmp    1054f0 <alltraps>

00106146 <vector195>:
.globl vector195
vector195:
  pushl $0
  106146:	6a 00                	push   $0x0
  pushl $195
  106148:	68 c3 00 00 00       	push   $0xc3
  jmp alltraps
  10614d:	e9 9e f3 ff ff       	jmp    1054f0 <alltraps>

00106152 <vector196>:
.globl vector196
vector196:
  pushl $0
  106152:	6a 00                	push   $0x0
  pushl $196
  106154:	68 c4 00 00 00       	push   $0xc4
  jmp alltraps
  106159:	e9 92 f3 ff ff       	jmp    1054f0 <alltraps>

0010615e <vector197>:
.globl vector197
vector197:
  pushl $0
  10615e:	6a 00                	push   $0x0
  pushl $197
  106160:	68 c5 00 00 00       	push   $0xc5
  jmp alltraps
  106165:	e9 86 f3 ff ff       	jmp    1054f0 <alltraps>

0010616a <vector198>:
.globl vector198
vector198:
  pushl $0
  10616a:	6a 00                	push   $0x0
  pushl $198
  10616c:	68 c6 00 00 00       	push   $0xc6
  jmp alltraps
  106171:	e9 7a f3 ff ff       	jmp    1054f0 <alltraps>

00106176 <vector199>:
.globl vector199
vector199:
  pushl $0
  106176:	6a 00                	push   $0x0
  pushl $199
  106178:	68 c7 00 00 00       	push   $0xc7
  jmp alltraps
  10617d:	e9 6e f3 ff ff       	jmp    1054f0 <alltraps>

00106182 <vector200>:
.globl vector200
vector200:
  pushl $0
  106182:	6a 00                	push   $0x0
  pushl $200
  106184:	68 c8 00 00 00       	push   $0xc8
  jmp alltraps
  106189:	e9 62 f3 ff ff       	jmp    1054f0 <alltraps>

0010618e <vector201>:
.globl vector201
vector201:
  pushl $0
  10618e:	6a 00                	push   $0x0
  pushl $201
  106190:	68 c9 00 00 00       	push   $0xc9
  jmp alltraps
  106195:	e9 56 f3 ff ff       	jmp    1054f0 <alltraps>

0010619a <vector202>:
.globl vector202
vector202:
  pushl $0
  10619a:	6a 00                	push   $0x0
  pushl $202
  10619c:	68 ca 00 00 00       	push   $0xca
  jmp alltraps
  1061a1:	e9 4a f3 ff ff       	jmp    1054f0 <alltraps>

001061a6 <vector203>:
.globl vector203
vector203:
  pushl $0
  1061a6:	6a 00                	push   $0x0
  pushl $203
  1061a8:	68 cb 00 00 00       	push   $0xcb
  jmp alltraps
  1061ad:	e9 3e f3 ff ff       	jmp    1054f0 <alltraps>

001061b2 <vector204>:
.globl vector204
vector204:
  pushl $0
  1061b2:	6a 00                	push   $0x0
  pushl $204
  1061b4:	68 cc 00 00 00       	push   $0xcc
  jmp alltraps
  1061b9:	e9 32 f3 ff ff       	jmp    1054f0 <alltraps>

001061be <vector205>:
.globl vector205
vector205:
  pushl $0
  1061be:	6a 00                	push   $0x0
  pushl $205
  1061c0:	68 cd 00 00 00       	push   $0xcd
  jmp alltraps
  1061c5:	e9 26 f3 ff ff       	jmp    1054f0 <alltraps>

001061ca <vector206>:
.globl vector206
vector206:
  pushl $0
  1061ca:	6a 00                	push   $0x0
  pushl $206
  1061cc:	68 ce 00 00 00       	push   $0xce
  jmp alltraps
  1061d1:	e9 1a f3 ff ff       	jmp    1054f0 <alltraps>

001061d6 <vector207>:
.globl vector207
vector207:
  pushl $0
  1061d6:	6a 00                	push   $0x0
  pushl $207
  1061d8:	68 cf 00 00 00       	push   $0xcf
  jmp alltraps
  1061dd:	e9 0e f3 ff ff       	jmp    1054f0 <alltraps>

001061e2 <vector208>:
.globl vector208
vector208:
  pushl $0
  1061e2:	6a 00                	push   $0x0
  pushl $208
  1061e4:	68 d0 00 00 00       	push   $0xd0
  jmp alltraps
  1061e9:	e9 02 f3 ff ff       	jmp    1054f0 <alltraps>

001061ee <vector209>:
.globl vector209
vector209:
  pushl $0
  1061ee:	6a 00                	push   $0x0
  pushl $209
  1061f0:	68 d1 00 00 00       	push   $0xd1
  jmp alltraps
  1061f5:	e9 f6 f2 ff ff       	jmp    1054f0 <alltraps>

001061fa <vector210>:
.globl vector210
vector210:
  pushl $0
  1061fa:	6a 00                	push   $0x0
  pushl $210
  1061fc:	68 d2 00 00 00       	push   $0xd2
  jmp alltraps
  106201:	e9 ea f2 ff ff       	jmp    1054f0 <alltraps>

00106206 <vector211>:
.globl vector211
vector211:
  pushl $0
  106206:	6a 00                	push   $0x0
  pushl $211
  106208:	68 d3 00 00 00       	push   $0xd3
  jmp alltraps
  10620d:	e9 de f2 ff ff       	jmp    1054f0 <alltraps>

00106212 <vector212>:
.globl vector212
vector212:
  pushl $0
  106212:	6a 00                	push   $0x0
  pushl $212
  106214:	68 d4 00 00 00       	push   $0xd4
  jmp alltraps
  106219:	e9 d2 f2 ff ff       	jmp    1054f0 <alltraps>

0010621e <vector213>:
.globl vector213
vector213:
  pushl $0
  10621e:	6a 00                	push   $0x0
  pushl $213
  106220:	68 d5 00 00 00       	push   $0xd5
  jmp alltraps
  106225:	e9 c6 f2 ff ff       	jmp    1054f0 <alltraps>

0010622a <vector214>:
.globl vector214
vector214:
  pushl $0
  10622a:	6a 00                	push   $0x0
  pushl $214
  10622c:	68 d6 00 00 00       	push   $0xd6
  jmp alltraps
  106231:	e9 ba f2 ff ff       	jmp    1054f0 <alltraps>

00106236 <vector215>:
.globl vector215
vector215:
  pushl $0
  106236:	6a 00                	push   $0x0
  pushl $215
  106238:	68 d7 00 00 00       	push   $0xd7
  jmp alltraps
  10623d:	e9 ae f2 ff ff       	jmp    1054f0 <alltraps>

00106242 <vector216>:
.globl vector216
vector216:
  pushl $0
  106242:	6a 00                	push   $0x0
  pushl $216
  106244:	68 d8 00 00 00       	push   $0xd8
  jmp alltraps
  106249:	e9 a2 f2 ff ff       	jmp    1054f0 <alltraps>

0010624e <vector217>:
.globl vector217
vector217:
  pushl $0
  10624e:	6a 00                	push   $0x0
  pushl $217
  106250:	68 d9 00 00 00       	push   $0xd9
  jmp alltraps
  106255:	e9 96 f2 ff ff       	jmp    1054f0 <alltraps>

0010625a <vector218>:
.globl vector218
vector218:
  pushl $0
  10625a:	6a 00                	push   $0x0
  pushl $218
  10625c:	68 da 00 00 00       	push   $0xda
  jmp alltraps
  106261:	e9 8a f2 ff ff       	jmp    1054f0 <alltraps>

00106266 <vector219>:
.globl vector219
vector219:
  pushl $0
  106266:	6a 00                	push   $0x0
  pushl $219
  106268:	68 db 00 00 00       	push   $0xdb
  jmp alltraps
  10626d:	e9 7e f2 ff ff       	jmp    1054f0 <alltraps>

00106272 <vector220>:
.globl vector220
vector220:
  pushl $0
  106272:	6a 00                	push   $0x0
  pushl $220
  106274:	68 dc 00 00 00       	push   $0xdc
  jmp alltraps
  106279:	e9 72 f2 ff ff       	jmp    1054f0 <alltraps>

0010627e <vector221>:
.globl vector221
vector221:
  pushl $0
  10627e:	6a 00                	push   $0x0
  pushl $221
  106280:	68 dd 00 00 00       	push   $0xdd
  jmp alltraps
  106285:	e9 66 f2 ff ff       	jmp    1054f0 <alltraps>

0010628a <vector222>:
.globl vector222
vector222:
  pushl $0
  10628a:	6a 00                	push   $0x0
  pushl $222
  10628c:	68 de 00 00 00       	push   $0xde
  jmp alltraps
  106291:	e9 5a f2 ff ff       	jmp    1054f0 <alltraps>

00106296 <vector223>:
.globl vector223
vector223:
  pushl $0
  106296:	6a 00                	push   $0x0
  pushl $223
  106298:	68 df 00 00 00       	push   $0xdf
  jmp alltraps
  10629d:	e9 4e f2 ff ff       	jmp    1054f0 <alltraps>

001062a2 <vector224>:
.globl vector224
vector224:
  pushl $0
  1062a2:	6a 00                	push   $0x0
  pushl $224
  1062a4:	68 e0 00 00 00       	push   $0xe0
  jmp alltraps
  1062a9:	e9 42 f2 ff ff       	jmp    1054f0 <alltraps>

001062ae <vector225>:
.globl vector225
vector225:
  pushl $0
  1062ae:	6a 00                	push   $0x0
  pushl $225
  1062b0:	68 e1 00 00 00       	push   $0xe1
  jmp alltraps
  1062b5:	e9 36 f2 ff ff       	jmp    1054f0 <alltraps>

001062ba <vector226>:
.globl vector226
vector226:
  pushl $0
  1062ba:	6a 00                	push   $0x0
  pushl $226
  1062bc:	68 e2 00 00 00       	push   $0xe2
  jmp alltraps
  1062c1:	e9 2a f2 ff ff       	jmp    1054f0 <alltraps>

001062c6 <vector227>:
.globl vector227
vector227:
  pushl $0
  1062c6:	6a 00                	push   $0x0
  pushl $227
  1062c8:	68 e3 00 00 00       	push   $0xe3
  jmp alltraps
  1062cd:	e9 1e f2 ff ff       	jmp    1054f0 <alltraps>

001062d2 <vector228>:
.globl vector228
vector228:
  pushl $0
  1062d2:	6a 00                	push   $0x0
  pushl $228
  1062d4:	68 e4 00 00 00       	push   $0xe4
  jmp alltraps
  1062d9:	e9 12 f2 ff ff       	jmp    1054f0 <alltraps>

001062de <vector229>:
.globl vector229
vector229:
  pushl $0
  1062de:	6a 00                	push   $0x0
  pushl $229
  1062e0:	68 e5 00 00 00       	push   $0xe5
  jmp alltraps
  1062e5:	e9 06 f2 ff ff       	jmp    1054f0 <alltraps>

001062ea <vector230>:
.globl vector230
vector230:
  pushl $0
  1062ea:	6a 00                	push   $0x0
  pushl $230
  1062ec:	68 e6 00 00 00       	push   $0xe6
  jmp alltraps
  1062f1:	e9 fa f1 ff ff       	jmp    1054f0 <alltraps>

001062f6 <vector231>:
.globl vector231
vector231:
  pushl $0
  1062f6:	6a 00                	push   $0x0
  pushl $231
  1062f8:	68 e7 00 00 00       	push   $0xe7
  jmp alltraps
  1062fd:	e9 ee f1 ff ff       	jmp    1054f0 <alltraps>

00106302 <vector232>:
.globl vector232
vector232:
  pushl $0
  106302:	6a 00                	push   $0x0
  pushl $232
  106304:	68 e8 00 00 00       	push   $0xe8
  jmp alltraps
  106309:	e9 e2 f1 ff ff       	jmp    1054f0 <alltraps>

0010630e <vector233>:
.globl vector233
vector233:
  pushl $0
  10630e:	6a 00                	push   $0x0
  pushl $233
  106310:	68 e9 00 00 00       	push   $0xe9
  jmp alltraps
  106315:	e9 d6 f1 ff ff       	jmp    1054f0 <alltraps>

0010631a <vector234>:
.globl vector234
vector234:
  pushl $0
  10631a:	6a 00                	push   $0x0
  pushl $234
  10631c:	68 ea 00 00 00       	push   $0xea
  jmp alltraps
  106321:	e9 ca f1 ff ff       	jmp    1054f0 <alltraps>

00106326 <vector235>:
.globl vector235
vector235:
  pushl $0
  106326:	6a 00                	push   $0x0
  pushl $235
  106328:	68 eb 00 00 00       	push   $0xeb
  jmp alltraps
  10632d:	e9 be f1 ff ff       	jmp    1054f0 <alltraps>

00106332 <vector236>:
.globl vector236
vector236:
  pushl $0
  106332:	6a 00                	push   $0x0
  pushl $236
  106334:	68 ec 00 00 00       	push   $0xec
  jmp alltraps
  106339:	e9 b2 f1 ff ff       	jmp    1054f0 <alltraps>

0010633e <vector237>:
.globl vector237
vector237:
  pushl $0
  10633e:	6a 00                	push   $0x0
  pushl $237
  106340:	68 ed 00 00 00       	push   $0xed
  jmp alltraps
  106345:	e9 a6 f1 ff ff       	jmp    1054f0 <alltraps>

0010634a <vector238>:
.globl vector238
vector238:
  pushl $0
  10634a:	6a 00                	push   $0x0
  pushl $238
  10634c:	68 ee 00 00 00       	push   $0xee
  jmp alltraps
  106351:	e9 9a f1 ff ff       	jmp    1054f0 <alltraps>

00106356 <vector239>:
.globl vector239
vector239:
  pushl $0
  106356:	6a 00                	push   $0x0
  pushl $239
  106358:	68 ef 00 00 00       	push   $0xef
  jmp alltraps
  10635d:	e9 8e f1 ff ff       	jmp    1054f0 <alltraps>

00106362 <vector240>:
.globl vector240
vector240:
  pushl $0
  106362:	6a 00                	push   $0x0
  pushl $240
  106364:	68 f0 00 00 00       	push   $0xf0
  jmp alltraps
  106369:	e9 82 f1 ff ff       	jmp    1054f0 <alltraps>

0010636e <vector241>:
.globl vector241
vector241:
  pushl $0
  10636e:	6a 00                	push   $0x0
  pushl $241
  106370:	68 f1 00 00 00       	push   $0xf1
  jmp alltraps
  106375:	e9 76 f1 ff ff       	jmp    1054f0 <alltraps>

0010637a <vector242>:
.globl vector242
vector242:
  pushl $0
  10637a:	6a 00                	push   $0x0
  pushl $242
  10637c:	68 f2 00 00 00       	push   $0xf2
  jmp alltraps
  106381:	e9 6a f1 ff ff       	jmp    1054f0 <alltraps>

00106386 <vector243>:
.globl vector243
vector243:
  pushl $0
  106386:	6a 00                	push   $0x0
  pushl $243
  106388:	68 f3 00 00 00       	push   $0xf3
  jmp alltraps
  10638d:	e9 5e f1 ff ff       	jmp    1054f0 <alltraps>

00106392 <vector244>:
.globl vector244
vector244:
  pushl $0
  106392:	6a 00                	push   $0x0
  pushl $244
  106394:	68 f4 00 00 00       	push   $0xf4
  jmp alltraps
  106399:	e9 52 f1 ff ff       	jmp    1054f0 <alltraps>

0010639e <vector245>:
.globl vector245
vector245:
  pushl $0
  10639e:	6a 00                	push   $0x0
  pushl $245
  1063a0:	68 f5 00 00 00       	push   $0xf5
  jmp alltraps
  1063a5:	e9 46 f1 ff ff       	jmp    1054f0 <alltraps>

001063aa <vector246>:
.globl vector246
vector246:
  pushl $0
  1063aa:	6a 00                	push   $0x0
  pushl $246
  1063ac:	68 f6 00 00 00       	push   $0xf6
  jmp alltraps
  1063b1:	e9 3a f1 ff ff       	jmp    1054f0 <alltraps>

001063b6 <vector247>:
.globl vector247
vector247:
  pushl $0
  1063b6:	6a 00                	push   $0x0
  pushl $247
  1063b8:	68 f7 00 00 00       	push   $0xf7
  jmp alltraps
  1063bd:	e9 2e f1 ff ff       	jmp    1054f0 <alltraps>

001063c2 <vector248>:
.globl vector248
vector248:
  pushl $0
  1063c2:	6a 00                	push   $0x0
  pushl $248
  1063c4:	68 f8 00 00 00       	push   $0xf8
  jmp alltraps
  1063c9:	e9 22 f1 ff ff       	jmp    1054f0 <alltraps>

001063ce <vector249>:
.globl vector249
vector249:
  pushl $0
  1063ce:	6a 00                	push   $0x0
  pushl $249
  1063d0:	68 f9 00 00 00       	push   $0xf9
  jmp alltraps
  1063d5:	e9 16 f1 ff ff       	jmp    1054f0 <alltraps>

001063da <vector250>:
.globl vector250
vector250:
  pushl $0
  1063da:	6a 00                	push   $0x0
  pushl $250
  1063dc:	68 fa 00 00 00       	push   $0xfa
  jmp alltraps
  1063e1:	e9 0a f1 ff ff       	jmp    1054f0 <alltraps>

001063e6 <vector251>:
.globl vector251
vector251:
  pushl $0
  1063e6:	6a 00                	push   $0x0
  pushl $251
  1063e8:	68 fb 00 00 00       	push   $0xfb
  jmp alltraps
  1063ed:	e9 fe f0 ff ff       	jmp    1054f0 <alltraps>

001063f2 <vector252>:
.globl vector252
vector252:
  pushl $0
  1063f2:	6a 00                	push   $0x0
  pushl $252
  1063f4:	68 fc 00 00 00       	push   $0xfc
  jmp alltraps
  1063f9:	e9 f2 f0 ff ff       	jmp    1054f0 <alltraps>

001063fe <vector253>:
.globl vector253
vector253:
  pushl $0
  1063fe:	6a 00                	push   $0x0
  pushl $253
  106400:	68 fd 00 00 00       	push   $0xfd
  jmp alltraps
  106405:	e9 e6 f0 ff ff       	jmp    1054f0 <alltraps>

0010640a <vector254>:
.globl vector254
vector254:
  pushl $0
  10640a:	6a 00                	push   $0x0
  pushl $254
  10640c:	68 fe 00 00 00       	push   $0xfe
  jmp alltraps
  106411:	e9 da f0 ff ff       	jmp    1054f0 <alltraps>

00106416 <vector255>:
.globl vector255
vector255:
  pushl $0
  106416:	6a 00                	push   $0x0
  pushl $255
  106418:	68 ff 00 00 00       	push   $0xff
  jmp alltraps
  10641d:	e9 ce f0 ff ff       	jmp    1054f0 <alltraps>
  106422:	90                   	nop
  106423:	90                   	nop
  106424:	90                   	nop
  106425:	90                   	nop
  106426:	90                   	nop
  106427:	90                   	nop
  106428:	90                   	nop
  106429:	90                   	nop
  10642a:	90                   	nop
  10642b:	90                   	nop
  10642c:	90                   	nop
  10642d:	90                   	nop
  10642e:	90                   	nop
  10642f:	90                   	nop

00106430 <vmenable>:
}

// Turn on paging.
void
vmenable(void)
{
  106430:	55                   	push   %ebp
}

static inline void
lcr3(uint val) 
{
  asm volatile("movl %0,%%cr3" : : "r" (val));
  106431:	a1 d4 95 10 00       	mov    0x1095d4,%eax
  106436:	89 e5                	mov    %esp,%ebp
  106438:	0f 22 d8             	mov    %eax,%cr3

static inline uint
rcr0(void)
{
  uint val;
  asm volatile("movl %%cr0,%0" : "=r" (val));
  10643b:	0f 20 c0             	mov    %cr0,%eax
}

static inline void
lcr0(uint val)
{
  asm volatile("movl %0,%%cr0" : : "r" (val));
  10643e:	0d 00 00 00 80       	or     $0x80000000,%eax
  106443:	0f 22 c0             	mov    %eax,%cr0

  switchkvm(); // load kpgdir into cr3
  cr0 = rcr0();
  cr0 |= CR0_PG;
  lcr0(cr0);
}
  106446:	5d                   	pop    %ebp
  106447:	c3                   	ret    
  106448:	90                   	nop
  106449:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00106450 <switchkvm>:

// Switch h/w page table register to the kernel-only page table,
// for when no process is running.
void
switchkvm()
{
  106450:	55                   	push   %ebp
}

static inline void
lcr3(uint val) 
{
  asm volatile("movl %0,%%cr3" : : "r" (val));
  106451:	a1 d4 95 10 00       	mov    0x1095d4,%eax
  106456:	89 e5                	mov    %esp,%ebp
  106458:	0f 22 d8             	mov    %eax,%cr3
  lcr3(PADDR(kpgdir));   // switch to the kernel page table
}
  10645b:	5d                   	pop    %ebp
  10645c:	c3                   	ret    
  10645d:	8d 76 00             	lea    0x0(%esi),%esi

00106460 <walkpgdir>:
// Return the address of the PTE in page table pgdir
// that corresponds to linear address va.  If create!=0,
// create any required page table pages.
static pte_t *
walkpgdir(pde_t *pgdir, const void *va, int create)
{
  106460:	55                   	push   %ebp
  106461:	89 e5                	mov    %esp,%ebp
  106463:	83 ec 28             	sub    $0x28,%esp
  106466:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  uint r;
  pde_t *pde;
  pte_t *pgtab;

  pde = &pgdir[PDX(va)];
  106469:	89 d3                	mov    %edx,%ebx
  10646b:	c1 eb 16             	shr    $0x16,%ebx
  10646e:	8d 1c 98             	lea    (%eax,%ebx,4),%ebx
// Return the address of the PTE in page table pgdir
// that corresponds to linear address va.  If create!=0,
// create any required page table pages.
static pte_t *
walkpgdir(pde_t *pgdir, const void *va, int create)
{
  106471:	89 75 fc             	mov    %esi,-0x4(%ebp)
  uint r;
  pde_t *pde;
  pte_t *pgtab;

  pde = &pgdir[PDX(va)];
  if(*pde & PTE_P){
  106474:	8b 33                	mov    (%ebx),%esi
  106476:	f7 c6 01 00 00 00    	test   $0x1,%esi
  10647c:	74 22                	je     1064a0 <walkpgdir+0x40>
    pgtab = (pte_t*) PTE_ADDR(*pde);
  10647e:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
    // The permissions here are overly generous, but they can
    // be further restricted by the permissions in the page table 
    // entries, if necessary.
    *pde = PADDR(r) | PTE_P | PTE_W | PTE_U;
  }
  return &pgtab[PTX(va)];
  106484:	c1 ea 0a             	shr    $0xa,%edx
  106487:	81 e2 fc 0f 00 00    	and    $0xffc,%edx
  10648d:	8d 04 16             	lea    (%esi,%edx,1),%eax
}
  106490:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  106493:	8b 75 fc             	mov    -0x4(%ebp),%esi
  106496:	89 ec                	mov    %ebp,%esp
  106498:	5d                   	pop    %ebp
  106499:	c3                   	ret    
  10649a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  pte_t *pgtab;

  pde = &pgdir[PDX(va)];
  if(*pde & PTE_P){
    pgtab = (pte_t*) PTE_ADDR(*pde);
  } else if(!create || !(r = (uint) kalloc()))
  1064a0:	85 c9                	test   %ecx,%ecx
  1064a2:	75 04                	jne    1064a8 <walkpgdir+0x48>
    // The permissions here are overly generous, but they can
    // be further restricted by the permissions in the page table 
    // entries, if necessary.
    *pde = PADDR(r) | PTE_P | PTE_W | PTE_U;
  }
  return &pgtab[PTX(va)];
  1064a4:	31 c0                	xor    %eax,%eax
  1064a6:	eb e8                	jmp    106490 <walkpgdir+0x30>
  pte_t *pgtab;

  pde = &pgdir[PDX(va)];
  if(*pde & PTE_P){
    pgtab = (pte_t*) PTE_ADDR(*pde);
  } else if(!create || !(r = (uint) kalloc()))
  1064a8:	89 55 f4             	mov    %edx,-0xc(%ebp)
  1064ab:	90                   	nop
  1064ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  1064b0:	e8 4b bf ff ff       	call   102400 <kalloc>
  1064b5:	85 c0                	test   %eax,%eax
  1064b7:	74 eb                	je     1064a4 <walkpgdir+0x44>
    return 0;
  else {
    pgtab = (pte_t*) r;
  1064b9:	89 c6                	mov    %eax,%esi
    // Make sure all those PTE_P bits are zero.
    memset(pgtab, 0, PGSIZE);
  1064bb:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  1064c2:	00 
  1064c3:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  1064ca:	00 
  1064cb:	89 04 24             	mov    %eax,(%esp)
  1064ce:	e8 8d de ff ff       	call   104360 <memset>
    // The permissions here are overly generous, but they can
    // be further restricted by the permissions in the page table 
    // entries, if necessary.
    *pde = PADDR(r) | PTE_P | PTE_W | PTE_U;
  1064d3:	89 f0                	mov    %esi,%eax
  1064d5:	83 c8 07             	or     $0x7,%eax
  1064d8:	89 03                	mov    %eax,(%ebx)
  1064da:	8b 55 f4             	mov    -0xc(%ebp),%edx
  1064dd:	eb a5                	jmp    106484 <walkpgdir+0x24>
  1064df:	90                   	nop

001064e0 <mappages>:
// Create PTEs for linear addresses starting at la that refer to
// physical addresses starting at pa. la and size might not
// be page-aligned.
static int
mappages(pde_t *pgdir, void *la, uint size, uint pa, int perm)
{
  1064e0:	55                   	push   %ebp
  1064e1:	89 e5                	mov    %esp,%ebp
  1064e3:	57                   	push   %edi
  1064e4:	56                   	push   %esi
  1064e5:	53                   	push   %ebx
  char *a = PGROUNDDOWN(la);
  1064e6:	89 d3                	mov    %edx,%ebx
  char *last = PGROUNDDOWN(la + size - 1);
  1064e8:	8d 7c 0a ff          	lea    -0x1(%edx,%ecx,1),%edi
// Create PTEs for linear addresses starting at la that refer to
// physical addresses starting at pa. la and size might not
// be page-aligned.
static int
mappages(pde_t *pgdir, void *la, uint size, uint pa, int perm)
{
  1064ec:	83 ec 2c             	sub    $0x2c,%esp
  1064ef:	8b 75 08             	mov    0x8(%ebp),%esi
  1064f2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  char *a = PGROUNDDOWN(la);
  1064f5:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
  char *last = PGROUNDDOWN(la + size - 1);
  1064fb:	81 e7 00 f0 ff ff    	and    $0xfffff000,%edi
    pte_t *pte = walkpgdir(pgdir, a, 1);
    if(pte == 0)
      return 0;
    if(*pte & PTE_P)
      panic("remap");
    *pte = pa | perm | PTE_P;
  106501:	83 4d 0c 01          	orl    $0x1,0xc(%ebp)
  106505:	eb 1d                	jmp    106524 <mappages+0x44>
  106507:	90                   	nop

  while(1){
    pte_t *pte = walkpgdir(pgdir, a, 1);
    if(pte == 0)
      return 0;
    if(*pte & PTE_P)
  106508:	f6 00 01             	testb  $0x1,(%eax)
  10650b:	75 48                	jne    106555 <mappages+0x75>
      panic("remap");
    *pte = pa | perm | PTE_P;
  10650d:	8b 55 0c             	mov    0xc(%ebp),%edx
  106510:	09 f2                	or     %esi,%edx
    if(a == last)
  106512:	39 fb                	cmp    %edi,%ebx
    pte_t *pte = walkpgdir(pgdir, a, 1);
    if(pte == 0)
      return 0;
    if(*pte & PTE_P)
      panic("remap");
    *pte = pa | perm | PTE_P;
  106514:	89 10                	mov    %edx,(%eax)
    if(a == last)
  106516:	74 30                	je     106548 <mappages+0x68>
      break;
    a += PGSIZE;
  106518:	81 c3 00 10 00 00    	add    $0x1000,%ebx
    pa += PGSIZE;
  10651e:	81 c6 00 10 00 00    	add    $0x1000,%esi
{
  char *a = PGROUNDDOWN(la);
  char *last = PGROUNDDOWN(la + size - 1);

  while(1){
    pte_t *pte = walkpgdir(pgdir, a, 1);
  106524:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  106527:	b9 01 00 00 00       	mov    $0x1,%ecx
  10652c:	89 da                	mov    %ebx,%edx
  10652e:	e8 2d ff ff ff       	call   106460 <walkpgdir>
    if(pte == 0)
  106533:	85 c0                	test   %eax,%eax
  106535:	75 d1                	jne    106508 <mappages+0x28>
      break;
    a += PGSIZE;
    pa += PGSIZE;
  }
  return 1;
}
  106537:	83 c4 2c             	add    $0x2c,%esp
    *pte = pa | perm | PTE_P;
    if(a == last)
      break;
    a += PGSIZE;
    pa += PGSIZE;
  }
  10653a:	31 c0                	xor    %eax,%eax
  return 1;
}
  10653c:	5b                   	pop    %ebx
  10653d:	5e                   	pop    %esi
  10653e:	5f                   	pop    %edi
  10653f:	5d                   	pop    %ebp
  106540:	c3                   	ret    
  106541:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  106548:	83 c4 2c             	add    $0x2c,%esp
    if(pte == 0)
      return 0;
    if(*pte & PTE_P)
      panic("remap");
    *pte = pa | perm | PTE_P;
    if(a == last)
  10654b:	b8 01 00 00 00       	mov    $0x1,%eax
      break;
    a += PGSIZE;
    pa += PGSIZE;
  }
  return 1;
}
  106550:	5b                   	pop    %ebx
  106551:	5e                   	pop    %esi
  106552:	5f                   	pop    %edi
  106553:	5d                   	pop    %ebp
  106554:	c3                   	ret    
  while(1){
    pte_t *pte = walkpgdir(pgdir, a, 1);
    if(pte == 0)
      return 0;
    if(*pte & PTE_P)
      panic("remap");
  106555:	c7 04 24 94 74 10 00 	movl   $0x107494,(%esp)
  10655c:	e8 ff a4 ff ff       	call   100a60 <panic>
  106561:	eb 0d                	jmp    106570 <uva2ka>
  106563:	90                   	nop
  106564:	90                   	nop
  106565:	90                   	nop
  106566:	90                   	nop
  106567:	90                   	nop
  106568:	90                   	nop
  106569:	90                   	nop
  10656a:	90                   	nop
  10656b:	90                   	nop
  10656c:	90                   	nop
  10656d:	90                   	nop
  10656e:	90                   	nop
  10656f:	90                   	nop

00106570 <uva2ka>:
// maps to.  The result is also a kernel logical address,
// since the kernel maps the physical memory allocated to user
// processes directly.
char*
uva2ka(pde_t *pgdir, char *uva)
{    
  106570:	55                   	push   %ebp
  pte_t *pte = walkpgdir(pgdir, uva, 0);
  106571:	31 c9                	xor    %ecx,%ecx
// maps to.  The result is also a kernel logical address,
// since the kernel maps the physical memory allocated to user
// processes directly.
char*
uva2ka(pde_t *pgdir, char *uva)
{    
  106573:	89 e5                	mov    %esp,%ebp
  106575:	83 ec 08             	sub    $0x8,%esp
  pte_t *pte = walkpgdir(pgdir, uva, 0);
  106578:	8b 55 0c             	mov    0xc(%ebp),%edx
  10657b:	8b 45 08             	mov    0x8(%ebp),%eax
  10657e:	e8 dd fe ff ff       	call   106460 <walkpgdir>
  106583:	89 c2                	mov    %eax,%edx
  if(pte == 0) return 0;
  106585:	31 c0                	xor    %eax,%eax
  106587:	85 d2                	test   %edx,%edx
  106589:	74 07                	je     106592 <uva2ka+0x22>
  uint pa = PTE_ADDR(*pte);
  return (char *)pa;
  10658b:	8b 02                	mov    (%edx),%eax
  10658d:	25 00 f0 ff ff       	and    $0xfffff000,%eax
}
  106592:	c9                   	leave  
  106593:	c3                   	ret    
  106594:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  10659a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

001065a0 <inituvm>:

// Load the initcode into address 0 of pgdir.
// sz must be less than a page.
void
inituvm(pde_t *pgdir, char *init, uint sz)
{
  1065a0:	55                   	push   %ebp
  1065a1:	89 e5                	mov    %esp,%ebp
  1065a3:	83 ec 38             	sub    $0x38,%esp
  1065a6:	8b 45 08             	mov    0x8(%ebp),%eax
  1065a9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  1065ac:	89 75 f8             	mov    %esi,-0x8(%ebp)
  1065af:	8b 75 10             	mov    0x10(%ebp),%esi
  1065b2:	89 7d fc             	mov    %edi,-0x4(%ebp)
  1065b5:	8b 7d 0c             	mov    0xc(%ebp),%edi
  1065b8:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  char *mem = kalloc();
  1065bb:	e8 40 be ff ff       	call   102400 <kalloc>
  if (sz >= PGSIZE)
  1065c0:	81 fe ff 0f 00 00    	cmp    $0xfff,%esi
// Load the initcode into address 0 of pgdir.
// sz must be less than a page.
void
inituvm(pde_t *pgdir, char *init, uint sz)
{
  char *mem = kalloc();
  1065c6:	89 c3                	mov    %eax,%ebx
  if (sz >= PGSIZE)
  1065c8:	77 4c                	ja     106616 <inituvm+0x76>
    panic("inituvm: more than a page");
  memset(mem, 0, PGSIZE);
  1065ca:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  1065d1:	00 
  1065d2:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  1065d9:	00 
  1065da:	89 04 24             	mov    %eax,(%esp)
  1065dd:	e8 7e dd ff ff       	call   104360 <memset>
  mappages(pgdir, 0, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  1065e2:	b9 00 10 00 00       	mov    $0x1000,%ecx
  1065e7:	31 d2                	xor    %edx,%edx
  1065e9:	89 1c 24             	mov    %ebx,(%esp)
  1065ec:	c7 44 24 04 06 00 00 	movl   $0x6,0x4(%esp)
  1065f3:	00 
  1065f4:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  1065f7:	e8 e4 fe ff ff       	call   1064e0 <mappages>
  memmove(mem, init, sz);
  1065fc:	89 75 10             	mov    %esi,0x10(%ebp)
}
  1065ff:	8b 75 f8             	mov    -0x8(%ebp),%esi
  char *mem = kalloc();
  if (sz >= PGSIZE)
    panic("inituvm: more than a page");
  memset(mem, 0, PGSIZE);
  mappages(pgdir, 0, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  memmove(mem, init, sz);
  106602:	89 7d 0c             	mov    %edi,0xc(%ebp)
}
  106605:	8b 7d fc             	mov    -0x4(%ebp),%edi
  char *mem = kalloc();
  if (sz >= PGSIZE)
    panic("inituvm: more than a page");
  memset(mem, 0, PGSIZE);
  mappages(pgdir, 0, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  memmove(mem, init, sz);
  106608:	89 5d 08             	mov    %ebx,0x8(%ebp)
}
  10660b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  10660e:	89 ec                	mov    %ebp,%esp
  106610:	5d                   	pop    %ebp
  char *mem = kalloc();
  if (sz >= PGSIZE)
    panic("inituvm: more than a page");
  memset(mem, 0, PGSIZE);
  mappages(pgdir, 0, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  memmove(mem, init, sz);
  106611:	e9 ca dd ff ff       	jmp    1043e0 <memmove>
void
inituvm(pde_t *pgdir, char *init, uint sz)
{
  char *mem = kalloc();
  if (sz >= PGSIZE)
    panic("inituvm: more than a page");
  106616:	c7 04 24 9a 74 10 00 	movl   $0x10749a,(%esp)
  10661d:	e8 3e a4 ff ff       	call   100a60 <panic>
  106622:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  106629:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00106630 <setupkvm>:
}

// Set up kernel part of a page table.
pde_t*
setupkvm(void)
{
  106630:	55                   	push   %ebp
  106631:	89 e5                	mov    %esp,%ebp
  106633:	53                   	push   %ebx
  106634:	83 ec 14             	sub    $0x14,%esp
  pde_t *pgdir;

  // Allocate page directory
  if(!(pgdir = (pde_t *) kalloc()))
  106637:	e8 c4 bd ff ff       	call   102400 <kalloc>
  10663c:	85 c0                	test   %eax,%eax
  10663e:	89 c3                	mov    %eax,%ebx
  106640:	75 0e                	jne    106650 <setupkvm+0x20>
     !mappages(pgdir, (void *)0x100000, PHYSTOP-0x100000, 0x100000, PTE_W) ||
     // Map devices such as ioapic, lapic, ...
     !mappages(pgdir, (void *)0xFE000000, 0x2000000, 0xFE000000, PTE_W))
    return 0;
  return pgdir;
}
  106642:	89 d8                	mov    %ebx,%eax
  106644:	83 c4 14             	add    $0x14,%esp
  106647:	5b                   	pop    %ebx
  106648:	5d                   	pop    %ebp
  106649:	c3                   	ret    
  10664a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  pde_t *pgdir;

  // Allocate page directory
  if(!(pgdir = (pde_t *) kalloc()))
    return 0;
  memset(pgdir, 0, PGSIZE);
  106650:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  106657:	00 
  106658:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  10665f:	00 
  106660:	89 04 24             	mov    %eax,(%esp)
  106663:	e8 f8 dc ff ff       	call   104360 <memset>
  if(// Map IO space from 640K to 1Mbyte
     !mappages(pgdir, (void *)USERTOP, 0x60000, USERTOP, PTE_W) ||
  106668:	b9 00 00 06 00       	mov    $0x60000,%ecx
  10666d:	ba 00 00 0a 00       	mov    $0xa0000,%edx
  106672:	89 d8                	mov    %ebx,%eax
  106674:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  10667b:	00 
  10667c:	c7 04 24 00 00 0a 00 	movl   $0xa0000,(%esp)
  106683:	e8 58 fe ff ff       	call   1064e0 <mappages>

  // Allocate page directory
  if(!(pgdir = (pde_t *) kalloc()))
    return 0;
  memset(pgdir, 0, PGSIZE);
  if(// Map IO space from 640K to 1Mbyte
  106688:	85 c0                	test   %eax,%eax
  10668a:	75 0a                	jne    106696 <setupkvm+0x66>
  10668c:	31 db                	xor    %ebx,%ebx
     !mappages(pgdir, (void *)0x100000, PHYSTOP-0x100000, 0x100000, PTE_W) ||
     // Map devices such as ioapic, lapic, ...
     !mappages(pgdir, (void *)0xFE000000, 0x2000000, 0xFE000000, PTE_W))
    return 0;
  return pgdir;
}
  10668e:	83 c4 14             	add    $0x14,%esp
  106691:	89 d8                	mov    %ebx,%eax
  106693:	5b                   	pop    %ebx
  106694:	5d                   	pop    %ebp
  106695:	c3                   	ret    
    return 0;
  memset(pgdir, 0, PGSIZE);
  if(// Map IO space from 640K to 1Mbyte
     !mappages(pgdir, (void *)USERTOP, 0x60000, USERTOP, PTE_W) ||
     // Map kernel and free memory pool
     !mappages(pgdir, (void *)0x100000, PHYSTOP-0x100000, 0x100000, PTE_W) ||
  106696:	b9 00 00 f0 00       	mov    $0xf00000,%ecx
  10669b:	ba 00 00 10 00       	mov    $0x100000,%edx
  1066a0:	89 d8                	mov    %ebx,%eax
  1066a2:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  1066a9:	00 
  1066aa:	c7 04 24 00 00 10 00 	movl   $0x100000,(%esp)
  1066b1:	e8 2a fe ff ff       	call   1064e0 <mappages>

  // Allocate page directory
  if(!(pgdir = (pde_t *) kalloc()))
    return 0;
  memset(pgdir, 0, PGSIZE);
  if(// Map IO space from 640K to 1Mbyte
  1066b6:	85 c0                	test   %eax,%eax
  1066b8:	74 d2                	je     10668c <setupkvm+0x5c>
     !mappages(pgdir, (void *)USERTOP, 0x60000, USERTOP, PTE_W) ||
     // Map kernel and free memory pool
     !mappages(pgdir, (void *)0x100000, PHYSTOP-0x100000, 0x100000, PTE_W) ||
     // Map devices such as ioapic, lapic, ...
     !mappages(pgdir, (void *)0xFE000000, 0x2000000, 0xFE000000, PTE_W))
  1066ba:	b9 00 00 00 02       	mov    $0x2000000,%ecx
  1066bf:	ba 00 00 00 fe       	mov    $0xfe000000,%edx
  1066c4:	89 d8                	mov    %ebx,%eax
  1066c6:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  1066cd:	00 
  1066ce:	c7 04 24 00 00 00 fe 	movl   $0xfe000000,(%esp)
  1066d5:	e8 06 fe ff ff       	call   1064e0 <mappages>

  // Allocate page directory
  if(!(pgdir = (pde_t *) kalloc()))
    return 0;
  memset(pgdir, 0, PGSIZE);
  if(// Map IO space from 640K to 1Mbyte
  1066da:	85 c0                	test   %eax,%eax
  1066dc:	0f 85 60 ff ff ff    	jne    106642 <setupkvm+0x12>
  1066e2:	eb a8                	jmp    10668c <setupkvm+0x5c>
  1066e4:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  1066ea:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

001066f0 <kvmalloc>:

// Allocate one page table for the machine for the kernel address
// space for scheduler processes.
void
kvmalloc(void)
{
  1066f0:	55                   	push   %ebp
  1066f1:	89 e5                	mov    %esp,%ebp
  1066f3:	83 ec 08             	sub    $0x8,%esp
  kpgdir = setupkvm();
  1066f6:	e8 35 ff ff ff       	call   106630 <setupkvm>
  1066fb:	a3 d4 95 10 00       	mov    %eax,0x1095d4
}
  106700:	c9                   	leave  
  106701:	c3                   	ret    
  106702:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  106709:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00106710 <deallocuvm>:
// newsz.  oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz.  oldsz can be larger than the actual
// process size.  Returns the new process size.
int
deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  106710:	55                   	push   %ebp
  106711:	89 e5                	mov    %esp,%ebp
  106713:	57                   	push   %edi
  106714:	56                   	push   %esi
  106715:	53                   	push   %ebx
  106716:	83 ec 2c             	sub    $0x2c,%esp
  char *a = (char *)PGROUNDUP(newsz);
  106719:	8b 5d 10             	mov    0x10(%ebp),%ebx
  char *last = PGROUNDDOWN(oldsz - 1);
  10671c:	8b 75 0c             	mov    0xc(%ebp),%esi
// newsz.  oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz.  oldsz can be larger than the actual
// process size.  Returns the new process size.
int
deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  10671f:	8b 7d 08             	mov    0x8(%ebp),%edi
  char *a = (char *)PGROUNDUP(newsz);
  106722:	81 c3 ff 0f 00 00    	add    $0xfff,%ebx
  char *last = PGROUNDDOWN(oldsz - 1);
  106728:	83 ee 01             	sub    $0x1,%esi
// need to be less than oldsz.  oldsz can be larger than the actual
// process size.  Returns the new process size.
int
deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  char *a = (char *)PGROUNDUP(newsz);
  10672b:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
  char *last = PGROUNDDOWN(oldsz - 1);
  106731:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  for(; a <= last; a += PGSIZE){
  106737:	39 f3                	cmp    %esi,%ebx
  106739:	77 41                	ja     10677c <deallocuvm+0x6c>
  10673b:	90                   	nop
  10673c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    pte_t *pte = walkpgdir(pgdir, a, 0);
  106740:	31 c9                	xor    %ecx,%ecx
  106742:	89 da                	mov    %ebx,%edx
  106744:	89 f8                	mov    %edi,%eax
  106746:	e8 15 fd ff ff       	call   106460 <walkpgdir>
    if(pte && (*pte & PTE_P) != 0){
  10674b:	85 c0                	test   %eax,%eax
  10674d:	74 23                	je     106772 <deallocuvm+0x62>
  10674f:	8b 10                	mov    (%eax),%edx
  106751:	f6 c2 01             	test   $0x1,%dl
  106754:	74 1c                	je     106772 <deallocuvm+0x62>
      uint pa = PTE_ADDR(*pte);
      if(pa == 0)
  106756:	81 e2 00 f0 ff ff    	and    $0xfffff000,%edx
  10675c:	74 3d                	je     10679b <deallocuvm+0x8b>
        panic("kfree");
      kfree((void *) pa);
  10675e:	89 14 24             	mov    %edx,(%esp)
  106761:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  106764:	e8 d7 bc ff ff       	call   102440 <kfree>
      *pte = 0;
  106769:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  10676c:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
int
deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  char *a = (char *)PGROUNDUP(newsz);
  char *last = PGROUNDDOWN(oldsz - 1);
  for(; a <= last; a += PGSIZE){
  106772:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  106778:	39 de                	cmp    %ebx,%esi
  10677a:	73 c4                	jae    106740 <deallocuvm+0x30>
  10677c:	8b 45 10             	mov    0x10(%ebp),%eax
  10677f:	3b 45 0c             	cmp    0xc(%ebp),%eax
  106782:	77 0c                	ja     106790 <deallocuvm+0x80>
      kfree((void *) pa);
      *pte = 0;
    }
  }
  return newsz < oldsz ? newsz : oldsz;
}
  106784:	83 c4 2c             	add    $0x2c,%esp
  106787:	5b                   	pop    %ebx
  106788:	5e                   	pop    %esi
  106789:	5f                   	pop    %edi
  10678a:	5d                   	pop    %ebp
  10678b:	c3                   	ret    
  10678c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
int
deallocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  char *a = (char *)PGROUNDUP(newsz);
  char *last = PGROUNDDOWN(oldsz - 1);
  for(; a <= last; a += PGSIZE){
  106790:	8b 45 0c             	mov    0xc(%ebp),%eax
      kfree((void *) pa);
      *pte = 0;
    }
  }
  return newsz < oldsz ? newsz : oldsz;
}
  106793:	83 c4 2c             	add    $0x2c,%esp
  106796:	5b                   	pop    %ebx
  106797:	5e                   	pop    %esi
  106798:	5f                   	pop    %edi
  106799:	5d                   	pop    %ebp
  10679a:	c3                   	ret    
  for(; a <= last; a += PGSIZE){
    pte_t *pte = walkpgdir(pgdir, a, 0);
    if(pte && (*pte & PTE_P) != 0){
      uint pa = PTE_ADDR(*pte);
      if(pa == 0)
        panic("kfree");
  10679b:	c7 04 24 36 6e 10 00 	movl   $0x106e36,(%esp)
  1067a2:	e8 b9 a2 ff ff       	call   100a60 <panic>
  1067a7:	89 f6                	mov    %esi,%esi
  1067a9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

001067b0 <freevm>:

// Free a page table and all the physical memory pages
// in the user part.
void
freevm(pde_t *pgdir)
{
  1067b0:	55                   	push   %ebp
  1067b1:	89 e5                	mov    %esp,%ebp
  1067b3:	56                   	push   %esi
  1067b4:	53                   	push   %ebx
  1067b5:	83 ec 10             	sub    $0x10,%esp
  1067b8:	8b 5d 08             	mov    0x8(%ebp),%ebx
  uint i;

  if(!pgdir)
  1067bb:	85 db                	test   %ebx,%ebx
  1067bd:	74 59                	je     106818 <freevm+0x68>
    panic("freevm: no pgdir");
  deallocuvm(pgdir, USERTOP, 0);
  1067bf:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  1067c6:	00 
  1067c7:	31 f6                	xor    %esi,%esi
  1067c9:	c7 44 24 04 00 00 0a 	movl   $0xa0000,0x4(%esp)
  1067d0:	00 
  1067d1:	89 1c 24             	mov    %ebx,(%esp)
  1067d4:	e8 37 ff ff ff       	call   106710 <deallocuvm>
  1067d9:	eb 10                	jmp    1067eb <freevm+0x3b>
  1067db:	90                   	nop
  1067dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  for(i = 0; i < NPDENTRIES; i++){
  1067e0:	83 c6 01             	add    $0x1,%esi
  1067e3:	81 fe 00 04 00 00    	cmp    $0x400,%esi
  1067e9:	74 1f                	je     10680a <freevm+0x5a>
    if(pgdir[i] & PTE_P)
  1067eb:	8b 04 b3             	mov    (%ebx,%esi,4),%eax
  1067ee:	a8 01                	test   $0x1,%al
  1067f0:	74 ee                	je     1067e0 <freevm+0x30>
      kfree((void *) PTE_ADDR(pgdir[i]));
  1067f2:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  uint i;

  if(!pgdir)
    panic("freevm: no pgdir");
  deallocuvm(pgdir, USERTOP, 0);
  for(i = 0; i < NPDENTRIES; i++){
  1067f7:	83 c6 01             	add    $0x1,%esi
    if(pgdir[i] & PTE_P)
      kfree((void *) PTE_ADDR(pgdir[i]));
  1067fa:	89 04 24             	mov    %eax,(%esp)
  1067fd:	e8 3e bc ff ff       	call   102440 <kfree>
  uint i;

  if(!pgdir)
    panic("freevm: no pgdir");
  deallocuvm(pgdir, USERTOP, 0);
  for(i = 0; i < NPDENTRIES; i++){
  106802:	81 fe 00 04 00 00    	cmp    $0x400,%esi
  106808:	75 e1                	jne    1067eb <freevm+0x3b>
    if(pgdir[i] & PTE_P)
      kfree((void *) PTE_ADDR(pgdir[i]));
  }
  kfree((void *) pgdir);
  10680a:	89 5d 08             	mov    %ebx,0x8(%ebp)
}
  10680d:	83 c4 10             	add    $0x10,%esp
  106810:	5b                   	pop    %ebx
  106811:	5e                   	pop    %esi
  106812:	5d                   	pop    %ebp
  deallocuvm(pgdir, USERTOP, 0);
  for(i = 0; i < NPDENTRIES; i++){
    if(pgdir[i] & PTE_P)
      kfree((void *) PTE_ADDR(pgdir[i]));
  }
  kfree((void *) pgdir);
  106813:	e9 28 bc ff ff       	jmp    102440 <kfree>
freevm(pde_t *pgdir)
{
  uint i;

  if(!pgdir)
    panic("freevm: no pgdir");
  106818:	c7 04 24 b4 74 10 00 	movl   $0x1074b4,(%esp)
  10681f:	e8 3c a2 ff ff       	call   100a60 <panic>
  106824:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  10682a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00106830 <copyuvm>:

// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  106830:	55                   	push   %ebp
  106831:	89 e5                	mov    %esp,%ebp
  106833:	57                   	push   %edi
  106834:	56                   	push   %esi
  106835:	53                   	push   %ebx
  106836:	83 ec 2c             	sub    $0x2c,%esp
  pde_t *d = setupkvm();
  106839:	e8 f2 fd ff ff       	call   106630 <setupkvm>
  pte_t *pte;
  uint pa, i;
  char *mem;

  if(!d) return 0;
  10683e:	85 c0                	test   %eax,%eax
// Given a parent process's page table, create a copy
// of it for a child.
pde_t*
copyuvm(pde_t *pgdir, uint sz)
{
  pde_t *d = setupkvm();
  106840:	89 c6                	mov    %eax,%esi
  pte_t *pte;
  uint pa, i;
  char *mem;

  if(!d) return 0;
  106842:	0f 84 84 00 00 00    	je     1068cc <copyuvm+0x9c>
  for(i = 0; i < sz; i += PGSIZE){
  106848:	8b 45 0c             	mov    0xc(%ebp),%eax
  10684b:	85 c0                	test   %eax,%eax
  10684d:	74 7d                	je     1068cc <copyuvm+0x9c>
  10684f:	31 db                	xor    %ebx,%ebx
  106851:	eb 47                	jmp    10689a <copyuvm+0x6a>
  106853:	90                   	nop
  106854:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present\n");
    pa = PTE_ADDR(*pte);
    if(!(mem = kalloc()))
      goto bad;
    memmove(mem, (char *)pa, PGSIZE);
  106858:	81 e2 00 f0 ff ff    	and    $0xfffff000,%edx
  10685e:	89 54 24 04          	mov    %edx,0x4(%esp)
  106862:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  106869:	00 
  10686a:	89 04 24             	mov    %eax,(%esp)
  10686d:	e8 6e db ff ff       	call   1043e0 <memmove>
    if(!mappages(d, (void *)i, PGSIZE, PADDR(mem), PTE_W|PTE_U))
  106872:	b9 00 10 00 00       	mov    $0x1000,%ecx
  106877:	89 da                	mov    %ebx,%edx
  106879:	89 f0                	mov    %esi,%eax
  10687b:	c7 44 24 04 06 00 00 	movl   $0x6,0x4(%esp)
  106882:	00 
  106883:	89 3c 24             	mov    %edi,(%esp)
  106886:	e8 55 fc ff ff       	call   1064e0 <mappages>
  10688b:	85 c0                	test   %eax,%eax
  10688d:	74 33                	je     1068c2 <copyuvm+0x92>
  pte_t *pte;
  uint pa, i;
  char *mem;

  if(!d) return 0;
  for(i = 0; i < sz; i += PGSIZE){
  10688f:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  106895:	39 5d 0c             	cmp    %ebx,0xc(%ebp)
  106898:	76 32                	jbe    1068cc <copyuvm+0x9c>
    if(!(pte = walkpgdir(pgdir, (void *)i, 0)))
  10689a:	8b 45 08             	mov    0x8(%ebp),%eax
  10689d:	31 c9                	xor    %ecx,%ecx
  10689f:	89 da                	mov    %ebx,%edx
  1068a1:	e8 ba fb ff ff       	call   106460 <walkpgdir>
  1068a6:	85 c0                	test   %eax,%eax
  1068a8:	74 2c                	je     1068d6 <copyuvm+0xa6>
      panic("copyuvm: pte should exist\n");
    if(!(*pte & PTE_P))
  1068aa:	8b 10                	mov    (%eax),%edx
  1068ac:	f6 c2 01             	test   $0x1,%dl
  1068af:	74 31                	je     1068e2 <copyuvm+0xb2>
      panic("copyuvm: page not present\n");
    pa = PTE_ADDR(*pte);
    if(!(mem = kalloc()))
  1068b1:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  1068b4:	e8 47 bb ff ff       	call   102400 <kalloc>
  1068b9:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  1068bc:	85 c0                	test   %eax,%eax
  1068be:	89 c7                	mov    %eax,%edi
  1068c0:	75 96                	jne    106858 <copyuvm+0x28>
      goto bad;
  }
  return d;

bad:
  freevm(d);
  1068c2:	89 34 24             	mov    %esi,(%esp)
  1068c5:	31 f6                	xor    %esi,%esi
  1068c7:	e8 e4 fe ff ff       	call   1067b0 <freevm>
  return 0;
}
  1068cc:	83 c4 2c             	add    $0x2c,%esp
  1068cf:	89 f0                	mov    %esi,%eax
  1068d1:	5b                   	pop    %ebx
  1068d2:	5e                   	pop    %esi
  1068d3:	5f                   	pop    %edi
  1068d4:	5d                   	pop    %ebp
  1068d5:	c3                   	ret    
  char *mem;

  if(!d) return 0;
  for(i = 0; i < sz; i += PGSIZE){
    if(!(pte = walkpgdir(pgdir, (void *)i, 0)))
      panic("copyuvm: pte should exist\n");
  1068d6:	c7 04 24 c5 74 10 00 	movl   $0x1074c5,(%esp)
  1068dd:	e8 7e a1 ff ff       	call   100a60 <panic>
    if(!(*pte & PTE_P))
      panic("copyuvm: page not present\n");
  1068e2:	c7 04 24 e0 74 10 00 	movl   $0x1074e0,(%esp)
  1068e9:	e8 72 a1 ff ff       	call   100a60 <panic>
  1068ee:	66 90                	xchg   %ax,%ax

001068f0 <allocuvm>:
// newsz. Allocates physical memory and page table entries. oldsz and
// newsz need not be page-aligned, nor does newsz have to be larger
// than oldsz.  Returns the new process size or 0 on error.
int
allocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  1068f0:	55                   	push   %ebp
  if(newsz > USERTOP)
  1068f1:	31 c0                	xor    %eax,%eax
// newsz. Allocates physical memory and page table entries. oldsz and
// newsz need not be page-aligned, nor does newsz have to be larger
// than oldsz.  Returns the new process size or 0 on error.
int
allocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  1068f3:	89 e5                	mov    %esp,%ebp
  1068f5:	57                   	push   %edi
  1068f6:	56                   	push   %esi
  1068f7:	53                   	push   %ebx
  1068f8:	83 ec 2c             	sub    $0x2c,%esp
  1068fb:	8b 7d 08             	mov    0x8(%ebp),%edi
  if(newsz > USERTOP)
  1068fe:	81 7d 10 00 00 0a 00 	cmpl   $0xa0000,0x10(%ebp)
  106905:	0f 87 93 00 00 00    	ja     10699e <allocuvm+0xae>
    return 0;
  char *a = (char *)PGROUNDUP(oldsz);
  10690b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  char *last = PGROUNDDOWN(newsz - 1);
  10690e:	8b 75 10             	mov    0x10(%ebp),%esi
int
allocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  if(newsz > USERTOP)
    return 0;
  char *a = (char *)PGROUNDUP(oldsz);
  106911:	81 c3 ff 0f 00 00    	add    $0xfff,%ebx
  char *last = PGROUNDDOWN(newsz - 1);
  106917:	83 ee 01             	sub    $0x1,%esi
int
allocuvm(pde_t *pgdir, uint oldsz, uint newsz)
{
  if(newsz > USERTOP)
    return 0;
  char *a = (char *)PGROUNDUP(oldsz);
  10691a:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
  char *last = PGROUNDDOWN(newsz - 1);
  106920:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  for (; a <= last; a += PGSIZE){
  106926:	39 f3                	cmp    %esi,%ebx
  106928:	76 47                	jbe    106971 <allocuvm+0x81>
  10692a:	eb 7c                	jmp    1069a8 <allocuvm+0xb8>
  10692c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    if(mem == 0){
      cprintf("allocuvm out of memory\n");
      deallocuvm(pgdir, newsz, oldsz);
      return 0;
    }
    memset(mem, 0, PGSIZE);
  106930:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  106937:	00 
  106938:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  10693f:	00 
  106940:	89 04 24             	mov    %eax,(%esp)
  106943:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  106946:	e8 15 da ff ff       	call   104360 <memset>
    mappages(pgdir, a, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  10694b:	b9 00 10 00 00       	mov    $0x1000,%ecx
  106950:	89 f8                	mov    %edi,%eax
  106952:	c7 44 24 04 06 00 00 	movl   $0x6,0x4(%esp)
  106959:	00 
  10695a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  10695d:	89 14 24             	mov    %edx,(%esp)
  106960:	89 da                	mov    %ebx,%edx
{
  if(newsz > USERTOP)
    return 0;
  char *a = (char *)PGROUNDUP(oldsz);
  char *last = PGROUNDDOWN(newsz - 1);
  for (; a <= last; a += PGSIZE){
  106962:	81 c3 00 10 00 00    	add    $0x1000,%ebx
      cprintf("allocuvm out of memory\n");
      deallocuvm(pgdir, newsz, oldsz);
      return 0;
    }
    memset(mem, 0, PGSIZE);
    mappages(pgdir, a, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  106968:	e8 73 fb ff ff       	call   1064e0 <mappages>
{
  if(newsz > USERTOP)
    return 0;
  char *a = (char *)PGROUNDUP(oldsz);
  char *last = PGROUNDDOWN(newsz - 1);
  for (; a <= last; a += PGSIZE){
  10696d:	39 de                	cmp    %ebx,%esi
  10696f:	72 37                	jb     1069a8 <allocuvm+0xb8>
    char *mem = kalloc();
  106971:	e8 8a ba ff ff       	call   102400 <kalloc>
    if(mem == 0){
  106976:	85 c0                	test   %eax,%eax
  106978:	75 b6                	jne    106930 <allocuvm+0x40>
      cprintf("allocuvm out of memory\n");
  10697a:	c7 04 24 fb 74 10 00 	movl   $0x1074fb,(%esp)
  106981:	e8 3a 9b ff ff       	call   1004c0 <cprintf>
      deallocuvm(pgdir, newsz, oldsz);
  106986:	8b 45 0c             	mov    0xc(%ebp),%eax
  106989:	89 44 24 08          	mov    %eax,0x8(%esp)
  10698d:	8b 45 10             	mov    0x10(%ebp),%eax
  106990:	89 3c 24             	mov    %edi,(%esp)
  106993:	89 44 24 04          	mov    %eax,0x4(%esp)
  106997:	e8 74 fd ff ff       	call   106710 <deallocuvm>
  10699c:	31 c0                	xor    %eax,%eax
    }
    memset(mem, 0, PGSIZE);
    mappages(pgdir, a, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  }
  return newsz > oldsz ? newsz : oldsz;
}
  10699e:	83 c4 2c             	add    $0x2c,%esp
  1069a1:	5b                   	pop    %ebx
  1069a2:	5e                   	pop    %esi
  1069a3:	5f                   	pop    %edi
  1069a4:	5d                   	pop    %ebp
  1069a5:	c3                   	ret    
  1069a6:	66 90                	xchg   %ax,%ax
      return 0;
    }
    memset(mem, 0, PGSIZE);
    mappages(pgdir, a, PGSIZE, PADDR(mem), PTE_W|PTE_U);
  }
  return newsz > oldsz ? newsz : oldsz;
  1069a8:	8b 45 10             	mov    0x10(%ebp),%eax
  1069ab:	3b 45 0c             	cmp    0xc(%ebp),%eax
  1069ae:	73 ee                	jae    10699e <allocuvm+0xae>
  1069b0:	8b 45 0c             	mov    0xc(%ebp),%eax
}
  1069b3:	83 c4 2c             	add    $0x2c,%esp
  1069b6:	5b                   	pop    %ebx
  1069b7:	5e                   	pop    %esi
  1069b8:	5f                   	pop    %edi
  1069b9:	5d                   	pop    %ebp
  1069ba:	c3                   	ret    
  1069bb:	90                   	nop
  1069bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

001069c0 <loaduvm>:

// Load a program segment into pgdir.  addr must be page-aligned
// and the pages from addr to addr+sz must already be mapped.
int
loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz)
{
  1069c0:	55                   	push   %ebp
  1069c1:	89 e5                	mov    %esp,%ebp
  1069c3:	57                   	push   %edi
  1069c4:	56                   	push   %esi
  1069c5:	53                   	push   %ebx
  1069c6:	83 ec 3c             	sub    $0x3c,%esp
  1069c9:	8b 7d 0c             	mov    0xc(%ebp),%edi
  uint i, pa, n;
  pte_t *pte;

  if((uint)addr % PGSIZE != 0)
  1069cc:	f7 c7 ff 0f 00 00    	test   $0xfff,%edi
  1069d2:	0f 85 99 00 00 00    	jne    106a71 <loaduvm+0xb1>
    panic("loaduvm: addr must be page aligned\n");
  1069d8:	8b 75 18             	mov    0x18(%ebp),%esi
  1069db:	31 db                	xor    %ebx,%ebx
  for(i = 0; i < sz; i += PGSIZE){
  1069dd:	85 f6                	test   %esi,%esi
  1069df:	74 77                	je     106a58 <loaduvm+0x98>
  1069e1:	89 7d d4             	mov    %edi,-0x2c(%ebp)
  1069e4:	eb 13                	jmp    1069f9 <loaduvm+0x39>
  1069e6:	66 90                	xchg   %ax,%ax
  1069e8:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  1069ee:	81 ee 00 10 00 00    	sub    $0x1000,%esi
  1069f4:	39 5d 18             	cmp    %ebx,0x18(%ebp)
  1069f7:	76 5f                	jbe    106a58 <loaduvm+0x98>
    if(!(pte = walkpgdir(pgdir, addr+i, 0)))
  1069f9:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  1069fc:	31 c9                	xor    %ecx,%ecx
  1069fe:	8b 45 08             	mov    0x8(%ebp),%eax
  106a01:	01 da                	add    %ebx,%edx
  106a03:	e8 58 fa ff ff       	call   106460 <walkpgdir>
  106a08:	85 c0                	test   %eax,%eax
  106a0a:	74 59                	je     106a65 <loaduvm+0xa5>
      panic("loaduvm: address should exist\n");
    pa = PTE_ADDR(*pte);
    if(sz - i < PGSIZE) n = sz - i;
  106a0c:	81 fe ff 0f 00 00    	cmp    $0xfff,%esi
  if((uint)addr % PGSIZE != 0)
    panic("loaduvm: addr must be page aligned\n");
  for(i = 0; i < sz; i += PGSIZE){
    if(!(pte = walkpgdir(pgdir, addr+i, 0)))
      panic("loaduvm: address should exist\n");
    pa = PTE_ADDR(*pte);
  106a12:	8b 00                	mov    (%eax),%eax
    if(sz - i < PGSIZE) n = sz - i;
  106a14:	ba 00 10 00 00       	mov    $0x1000,%edx
  106a19:	77 02                	ja     106a1d <loaduvm+0x5d>
  106a1b:	89 f2                	mov    %esi,%edx
    else n = PGSIZE;
    if(readi(ip, (char *)pa, offset+i, n) != n)
  106a1d:	89 54 24 0c          	mov    %edx,0xc(%esp)
  106a21:	8b 7d 14             	mov    0x14(%ebp),%edi
  106a24:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  106a29:	89 44 24 04          	mov    %eax,0x4(%esp)
  106a2d:	8d 0c 3b             	lea    (%ebx,%edi,1),%ecx
  106a30:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  106a34:	8b 45 10             	mov    0x10(%ebp),%eax
  106a37:	89 04 24             	mov    %eax,(%esp)
  106a3a:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  106a3d:	e8 be aa ff ff       	call   101500 <readi>
  106a42:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  106a45:	39 d0                	cmp    %edx,%eax
  106a47:	74 9f                	je     1069e8 <loaduvm+0x28>
      return 0;
  }
  return 1;
}
  106a49:	83 c4 3c             	add    $0x3c,%esp
    if(!(pte = walkpgdir(pgdir, addr+i, 0)))
      panic("loaduvm: address should exist\n");
    pa = PTE_ADDR(*pte);
    if(sz - i < PGSIZE) n = sz - i;
    else n = PGSIZE;
    if(readi(ip, (char *)pa, offset+i, n) != n)
  106a4c:	31 c0                	xor    %eax,%eax
      return 0;
  }
  return 1;
}
  106a4e:	5b                   	pop    %ebx
  106a4f:	5e                   	pop    %esi
  106a50:	5f                   	pop    %edi
  106a51:	5d                   	pop    %ebp
  106a52:	c3                   	ret    
  106a53:	90                   	nop
  106a54:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  106a58:	83 c4 3c             	add    $0x3c,%esp
  uint i, pa, n;
  pte_t *pte;

  if((uint)addr % PGSIZE != 0)
    panic("loaduvm: addr must be page aligned\n");
  for(i = 0; i < sz; i += PGSIZE){
  106a5b:	b8 01 00 00 00       	mov    $0x1,%eax
    else n = PGSIZE;
    if(readi(ip, (char *)pa, offset+i, n) != n)
      return 0;
  }
  return 1;
}
  106a60:	5b                   	pop    %ebx
  106a61:	5e                   	pop    %esi
  106a62:	5f                   	pop    %edi
  106a63:	5d                   	pop    %ebp
  106a64:	c3                   	ret    

  if((uint)addr % PGSIZE != 0)
    panic("loaduvm: addr must be page aligned\n");
  for(i = 0; i < sz; i += PGSIZE){
    if(!(pte = walkpgdir(pgdir, addr+i, 0)))
      panic("loaduvm: address should exist\n");
  106a65:	c7 04 24 4c 75 10 00 	movl   $0x10754c,(%esp)
  106a6c:	e8 ef 9f ff ff       	call   100a60 <panic>
{
  uint i, pa, n;
  pte_t *pte;

  if((uint)addr % PGSIZE != 0)
    panic("loaduvm: addr must be page aligned\n");
  106a71:	c7 04 24 28 75 10 00 	movl   $0x107528,(%esp)
  106a78:	e8 e3 9f ff ff       	call   100a60 <panic>
  106a7d:	8d 76 00             	lea    0x0(%esi),%esi

00106a80 <switchuvm>:
}

// Switch h/w page table and TSS registers to point to process p.
void
switchuvm(struct proc *p)
{
  106a80:	55                   	push   %ebp
  106a81:	89 e5                	mov    %esp,%ebp
  106a83:	53                   	push   %ebx
  106a84:	83 ec 14             	sub    $0x14,%esp
  106a87:	8b 5d 08             	mov    0x8(%ebp),%ebx
  pushcli();
  106a8a:	e8 41 d7 ff ff       	call   1041d0 <pushcli>

  // Setup TSS
  cpu->gdt[SEG_TSS] = SEG16(STS_T32A, &cpu->ts, sizeof(cpu->ts)-1, 0);
  106a8f:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  106a95:	8d 50 08             	lea    0x8(%eax),%edx
  106a98:	89 d1                	mov    %edx,%ecx
  106a9a:	66 89 90 a2 00 00 00 	mov    %dx,0xa2(%eax)
  106aa1:	c1 e9 10             	shr    $0x10,%ecx
  106aa4:	c1 ea 18             	shr    $0x18,%edx
  106aa7:	88 88 a4 00 00 00    	mov    %cl,0xa4(%eax)
  106aad:	c6 80 a5 00 00 00 99 	movb   $0x99,0xa5(%eax)
  106ab4:	88 90 a7 00 00 00    	mov    %dl,0xa7(%eax)
  106aba:	66 c7 80 a0 00 00 00 	movw   $0x67,0xa0(%eax)
  106ac1:	67 00 
  106ac3:	c6 80 a6 00 00 00 40 	movb   $0x40,0xa6(%eax)
  cpu->gdt[SEG_TSS].s = 0;
  106aca:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  106ad0:	80 a0 a5 00 00 00 ef 	andb   $0xef,0xa5(%eax)
  cpu->ts.ss0 = SEG_KDATA << 3;
  106ad7:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  106add:	66 c7 40 10 10 00    	movw   $0x10,0x10(%eax)
  cpu->ts.esp0 = (uint)proc->kstack + KSTACKSIZE;
  106ae3:	65 a1 04 00 00 00    	mov    %gs:0x4,%eax
  106ae9:	8b 50 08             	mov    0x8(%eax),%edx
  106aec:	65 a1 00 00 00 00    	mov    %gs:0x0,%eax
  106af2:	81 c2 00 10 00 00    	add    $0x1000,%edx
  106af8:	89 50 0c             	mov    %edx,0xc(%eax)
}

static inline void
ltr(ushort sel)
{
  asm volatile("ltr %0" : : "r" (sel));
  106afb:	b8 30 00 00 00       	mov    $0x30,%eax
  106b00:	0f 00 d8             	ltr    %ax
  ltr(SEG_TSS << 3);

  if(p->pgdir == 0)
  106b03:	8b 43 04             	mov    0x4(%ebx),%eax
  106b06:	85 c0                	test   %eax,%eax
  106b08:	74 0d                	je     106b17 <switchuvm+0x97>
}

static inline void
lcr3(uint val) 
{
  asm volatile("movl %0,%%cr3" : : "r" (val));
  106b0a:	0f 22 d8             	mov    %eax,%cr3
    panic("switchuvm: no pgdir\n");

  lcr3(PADDR(p->pgdir));  // switch to new address space
  popcli();
}
  106b0d:	83 c4 14             	add    $0x14,%esp
  106b10:	5b                   	pop    %ebx
  106b11:	5d                   	pop    %ebp

  if(p->pgdir == 0)
    panic("switchuvm: no pgdir\n");

  lcr3(PADDR(p->pgdir));  // switch to new address space
  popcli();
  106b12:	e9 f9 d6 ff ff       	jmp    104210 <popcli>
  cpu->ts.ss0 = SEG_KDATA << 3;
  cpu->ts.esp0 = (uint)proc->kstack + KSTACKSIZE;
  ltr(SEG_TSS << 3);

  if(p->pgdir == 0)
    panic("switchuvm: no pgdir\n");
  106b17:	c7 04 24 13 75 10 00 	movl   $0x107513,(%esp)
  106b1e:	e8 3d 9f ff ff       	call   100a60 <panic>
  106b23:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  106b29:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00106b30 <ksegment>:

// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
ksegment(void)
{
  106b30:	55                   	push   %ebp
  106b31:	89 e5                	mov    %esp,%ebp
  106b33:	83 ec 18             	sub    $0x18,%esp

  // Map virtual addresses to linear addresses using identity map.
  // Cannot share a CODE descriptor for both kernel and user
  // because it would have to have DPL_USR, but the CPU forbids
  // an interrupt from CPL=0 to DPL=3.
  c = &cpus[cpunum()];
  106b36:	e8 a5 bb ff ff       	call   1026e0 <cpunum>
  106b3b:	8d 04 40             	lea    (%eax,%eax,2),%eax
  106b3e:	c1 e0 06             	shl    $0x6,%eax
  106b41:	05 20 c8 10 00       	add    $0x10c820,%eax
  c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
  c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER);
  c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER);

  // Map cpu, and curproc
  c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);
  106b46:	8d 90 b4 00 00 00    	lea    0xb4(%eax),%edx
  106b4c:	66 89 90 8a 00 00 00 	mov    %dx,0x8a(%eax)
  106b53:	89 d1                	mov    %edx,%ecx
  106b55:	c1 ea 18             	shr    $0x18,%edx
  106b58:	88 90 8f 00 00 00    	mov    %dl,0x8f(%eax)
  106b5e:	c1 e9 10             	shr    $0x10,%ecx

  lgdt(c->gdt, sizeof(c->gdt));
  106b61:	8d 50 70             	lea    0x70(%eax),%edx
  // Map virtual addresses to linear addresses using identity map.
  // Cannot share a CODE descriptor for both kernel and user
  // because it would have to have DPL_USR, but the CPU forbids
  // an interrupt from CPL=0 to DPL=3.
  c = &cpus[cpunum()];
  c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0);
  106b64:	66 c7 40 78 ff ff    	movw   $0xffff,0x78(%eax)
  106b6a:	66 c7 40 7a 00 00    	movw   $0x0,0x7a(%eax)
  106b70:	c6 40 7c 00          	movb   $0x0,0x7c(%eax)
  106b74:	c6 40 7d 9a          	movb   $0x9a,0x7d(%eax)
  106b78:	c6 40 7e cf          	movb   $0xcf,0x7e(%eax)
  106b7c:	c6 40 7f 00          	movb   $0x0,0x7f(%eax)
  c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
  106b80:	66 c7 80 80 00 00 00 	movw   $0xffff,0x80(%eax)
  106b87:	ff ff 
  106b89:	66 c7 80 82 00 00 00 	movw   $0x0,0x82(%eax)
  106b90:	00 00 
  106b92:	c6 80 84 00 00 00 00 	movb   $0x0,0x84(%eax)
  106b99:	c6 80 85 00 00 00 92 	movb   $0x92,0x85(%eax)
  106ba0:	c6 80 86 00 00 00 cf 	movb   $0xcf,0x86(%eax)
  106ba7:	c6 80 87 00 00 00 00 	movb   $0x0,0x87(%eax)
  c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER);
  106bae:	66 c7 80 90 00 00 00 	movw   $0xffff,0x90(%eax)
  106bb5:	ff ff 
  106bb7:	66 c7 80 92 00 00 00 	movw   $0x0,0x92(%eax)
  106bbe:	00 00 
  106bc0:	c6 80 94 00 00 00 00 	movb   $0x0,0x94(%eax)
  106bc7:	c6 80 95 00 00 00 fa 	movb   $0xfa,0x95(%eax)
  106bce:	c6 80 96 00 00 00 cf 	movb   $0xcf,0x96(%eax)
  106bd5:	c6 80 97 00 00 00 00 	movb   $0x0,0x97(%eax)
  c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER);
  106bdc:	66 c7 80 98 00 00 00 	movw   $0xffff,0x98(%eax)
  106be3:	ff ff 
  106be5:	66 c7 80 9a 00 00 00 	movw   $0x0,0x9a(%eax)
  106bec:	00 00 
  106bee:	c6 80 9c 00 00 00 00 	movb   $0x0,0x9c(%eax)
  106bf5:	c6 80 9d 00 00 00 f2 	movb   $0xf2,0x9d(%eax)
  106bfc:	c6 80 9e 00 00 00 cf 	movb   $0xcf,0x9e(%eax)
  106c03:	c6 80 9f 00 00 00 00 	movb   $0x0,0x9f(%eax)

  // Map cpu, and curproc
  c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);
  106c0a:	66 c7 80 88 00 00 00 	movw   $0x0,0x88(%eax)
  106c11:	00 00 
  106c13:	88 88 8c 00 00 00    	mov    %cl,0x8c(%eax)
  106c19:	c6 80 8d 00 00 00 92 	movb   $0x92,0x8d(%eax)
  106c20:	c6 80 8e 00 00 00 c0 	movb   $0xc0,0x8e(%eax)
static inline void
lgdt(struct segdesc *p, int size)
{
  volatile ushort pd[3];

  pd[0] = size-1;
  106c27:	66 c7 45 f2 37 00    	movw   $0x37,-0xe(%ebp)
  pd[1] = (uint)p;
  106c2d:	66 89 55 f4          	mov    %dx,-0xc(%ebp)
  pd[2] = (uint)p >> 16;
  106c31:	c1 ea 10             	shr    $0x10,%edx
  106c34:	66 89 55 f6          	mov    %dx,-0xa(%ebp)

  asm volatile("lgdt (%0)" : : "r" (pd));
  106c38:	8d 55 f2             	lea    -0xe(%ebp),%edx
  106c3b:	0f 01 12             	lgdtl  (%edx)
}

static inline void
loadgs(ushort v)
{
  asm volatile("movw %0, %%gs" : : "r" (v));
  106c3e:	ba 18 00 00 00       	mov    $0x18,%edx
  106c43:	8e ea                	mov    %edx,%gs

  lgdt(c->gdt, sizeof(c->gdt));
  loadgs(SEG_KCPU << 3);
  
  // Initialize cpu-local storage.
  cpu = c;
  106c45:	65 a3 00 00 00 00    	mov    %eax,%gs:0x0
  proc = 0;
  106c4b:	65 c7 05 04 00 00 00 	movl   $0x0,%gs:0x4
  106c52:	00 00 00 00 
}
  106c56:	c9                   	leave  
  106c57:	c3                   	ret    
